0

I can't display the submenu of my menu when creating a plugin (Beginner). Could you please help me to find my error? My plugin is well activated and the menu_page appears well

add_action('admin_menu','tictac_admin_menu_option');

function tictac_admin_menu_option()
{
  add_menu_page(
  'Gestion des Horaires',
  'Time Control',
  'manage_options',
  'tictac_admin_menu',
  'tictac_scripts_page',
  //plugins_url( 'time-control/admin/logo/tictac-logo.png' ),
  'dashicons-calendar-alt'
  //16
  );
  add_submenu_page('tictac_admin_menu',
  'Sous menu Opening',
  'Options Opening',
  'tictac_admin_submenu',
  'tictac_scripts_menu',
  'tictac_opening_submenu'
  );

}
function tictac_opening_submenu()
{
  ?>
  <div id="wrap">
    <h1>Add Opening</h1>
  </div>
  <?php
}
0

The fourth parameter in add_submenu_page function is a capability. Try changing it to manage_options so your code looks like this:

add_submenu_page('tictac_admin_menu',
  'Sous menu Opening',
  'Options Opening',
  'manage_options',
  'tictac_scripts_menu',
  'tictac_opening_submenu'

);

Hope it helps

  • Thanks it works. But i don't understand why i must choose "Manage_options". The codex does not explain very well – Raphael Kuhn Mar 25 '18 at 13:06
  • You don't have to choose "manage_options" capability. I assumed you want this one, because you added it in the add_menu_page function. You have to pass any capability you want as the fourth parameter. You can find the list of available capabilities here: codex.wordpress.org/Roles_and_Capabilities "manage_options" is an administrator capability, so it means that only administrators will be able to access these pages – Raf Mar 26 '18 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.