I am able to add Menu to the Dashboard using the below code, it can be viewed by an administrator. That menu doesn’t appear when logged in as an Author or a Subscriber. How to make sure every user can view the custom added menus.
//Add Menu Page
add_action( 'admin_menu', 'register_my_custom_menu_page' );
function register_my_custom_menu_page(){
add_dashboard_page( 'custom menu title', 'Test', 'manage_options', 'custompage', 'my_custom_menu_page', plugins_url( 'test/images/icon.png' ), 6 );
}
function my_custom_menu_page(){
echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>';
echo '<h2>Test</h2>';
echo 'Test';
echo '</div>';
}
You have to use the right capability for this. You chose
manage_options
, which by default only users with an Administrator user role have.So, change it to
read
orexist
, for instance, and every user will be able to see and access the menu.