3

I have tried to created a menu page in WordPress back end but I can not view this page when I login with lower roles than admin!

Here is the code:

add_action('admin_menu', 'my_menu');

function my_menu(){
    add_menu_page('My Menu', 'My Menu', 'manage_options', 'my-menu-slug', 'my_menu_page_display');
}

function my_menu_page_display(){
    echo '<h1>Hello World</h1>';
    echo '<p>This is a My page</p>';
}

Please help me to view this menu page even if I login as lower role than admin

Prince
  • 51
  • 2

1 Answers1

0

Take a look at this link - https://developer.wordpress.org/reference/functions/add_menu_page/ - take a look at the 3rd parameter - 'capabilities', in your case you have put 'manage_options' which is administrator capability - https://codex.wordpress.org/Roles_and_Capabilities#Editor For all subscribers put 'read' But spend some time and take a look at the links

add_menu_page('My Menu', 'My Menu', 'read', 'my-menu-slug', 'my_menu_page_display');
Angel Deykov
  • 1,068
  • 1
  • 7
  • 14