Skip to content
Advertisement

Cannot access custom admin menu page WordPress

I’ve been trying to register custom admin menu using the following code

function bbtre_register_admin_page(){

   add_menu_page('Revenue Share Settings', 'Reshare', 'manage_options', 'reshare-settings', 'bbtre_admin_page_callback');

}

add_action('admin_init', 'bbtre_register_admin_page');

function bbtre_admin_page_callback(){

   echo "<h1>Hell</h1>";
}

The code is working well as I can see my custom admin menu appears on the dashboard, but when click on the menu, I found that I have no permission to access the page.

Here is the message: Sorry, you are not allowed to access this page.

I’ve been trying to find the solution on WordPress codes, but it deosn’t help even I change the capability ‘switch_themes’.

Anyone please kindly help me to solve the problem?

Note: I’m working on WordPress 9.4 and Xampp

Advertisement

Answer

Change the hook to add_action('admin_menu', 'bbtre_register_admin_page'); to add menu on admin dashboard

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement