Options page not displayed under Settings menu

<?php
/*
 *  Plugin Name: Official Treehouse Badges Plugin
 *  Plugin URI: http://wptreehouse.com/wptreehouse-badges-plugin/
 *  Description: Provides both widgets and shortcodes to help you display your Treehouse profile badges on your website.  The official Treehouse badges plugin.
 *  Version: 1.0
 *  Author: Editorial Staff
 *  Author URI: http://wp.zacgordon.com
 *  License: GPL2
 *
*/


/*---------------------------------------*/
/* 1. ASSIGN GLOBAL VARIABLE */
/*---------------------------------------*/


/*---------------------------------------*/
/* 2. PLUGIN ADMIN MENU */
/*---------------------------------------*/

function basic_treehouse_badges_menu() {
  /*
     *  Use the add_options_page function
     *  add_options_page( $page_title, $menu_title, $capability, $menu-slug, $function )
     *
    */
  add_options_page(
    'Official Tree House Badges Plugin',
    'Treehouse Badges',
    'manage options',
    'wp-treehouse-badges',
    'wptreehouse_badges_option_page'
  );
}
add_action('admin_menu','basic_treehouse_badges_menu');

function wptreehouse_badges_option_page() {
  if( !current_user_can ('manage_options')) {
    wp_die('You do not have sufficient permission to acces this page.');
  }
  echo '<p> welcome to our plugin page </p>';
}    


?>

I am just a beginner and have written a very simple basic plugin structure.

What’s the mistake that’s causing the “Treehouse Badges” menu name not to appear under the Settings menu in the admin section of WordPress.

2 Answers
2

The only issue was that the capability was specified incorrectly when using add_options_page(). The capability should be manage_options. Note the underscore, no space:

function basic_treehouse_badges_menu() {
  /*
     *  Use the add_options_page function
     *  add_options_page( $page_title, $menu_title, $capability, $menu-slug, $function )
     *
    */
  add_options_page(
    'Official Tree House Badges Plugin',
    'Treehouse Badges',
    'manage_options',
    'wp-treehouse-badges',
    'wptreehouse_badges_option_page'
  );
}
add_action('admin_menu','basic_treehouse_badges_menu');

function wptreehouse_badges_option_page() {
  if( !current_user_can ('manage_options')) {
    wp_die('You do not have sufficient permission to acces this page.');
  }
  echo '<p> welcome to our plugin page </p>';
}    

Leave a Comment