According to the documentation for add_menu_page:
Note: If you’re running into the “You do not have sufficient permissions to access this page” error, then you’ve hooked too early. The hook you should use is admin_menu.
This means you need to wrap your menu creation in something like:
add_action( 'admin_menu', function() {
add_menu_page(
// page title
'Page Title',
// menu title
'My Menu Title,
// capability
'some_capability,
// menu slug
'my-page',
// callback function
'do_my_page_content'
);
});
Related Posts:
- Add a Separator to the Admin Menu?
- Adding a custom admin page
- How to remove entire admin menu?
- Plugin to remove Admin menu items based on user role?
- Add my own button next to “Screen options” and “Help” in the admin
- How to show custom menu items in the WordPress android app?
- Remove ability to access certain admin menus
- Appearance->Editor not visible
- Custom WP_List_Table displays blank rows
- How do I set up a webhook?
- Admin pages have no content
- WordPress Left Hand Side Admin Menu Always Collapsed
- Reorder plugin items in the admin menu
- Re-ordering Admin Submenu Sections
- Reference external file as a function
- Add number new posts (post_status = pending) to administration menu [duplicate]
- add_submenu_page set for multiple roles [duplicate]
- How To Create User Specific Admin User Pages?
- Change the Default Pages Menu View in wp-admin
- How to change admin menu position of “Media”?
- Change top level menu item to point to custom submenu item
- Associating custom submenu item with post type of top level menu item
- Remove Admin sidebar link
- Single category’s posts list in admin menu
- Dashboard menu missing
- WordPress Remove Submenus
- page not updating with database
- Why am I timing out when using the Menu Editor?
- 500 internal server error on wp-admin only
- How can I POST or GET to the same admin page from which I am POST-ing or GET-ing
- Output the admin menu_position for each item
- avoiding the display of certain categories to certain user roles at content entry time
- How can I add a menu item to the admin area?
- Backend Checkboxes working – but not visual?
- WordPress Admin Menu Order for ‘admin.php’ pages
- Give admin_menu permission to specific users
- Show all admin menus in a table
- Highlight active Admin Menu when added though add_menu_page
- require/include php file in add_menu()
- Create WordPress Menu Item Without Linking to a Custom Page
- Simple CSS admin pagination
- How to change the default url for ‘Posts’ link?
- Unsure how to add simple checkboxes that write to a small table to admin
- Add a link to the Admin menu
- Reference external file as a function
- Display admin sidebar into custom post pages if logged
- Where in WP can I check history or log of updates of plugins etc?
- How does admin-ajax.php work?
- Editor Styles and Typekit
- WordPress admin stylesheet
- Is it possible to create a WordPress tour? V3.3.1
- Securing Admin Accounts – Username Discovery
- Is it OK to move admin menu items?
- Set Featured Image programmatically (in admin) with JavaScript?
- Can I set a default dashboard layout for all users?
- Taxonomy/category hierarchy lost when editing posts [closed]
- renaming an admin menu item with decimal array index number
- Making the thumbnails in the backend Media section bigger
- How to remove “Super Admin” from All Users for those that are not a “Super Admin”?
- Downloading entire site locally with httrack
- Adding markup to column text in “Edit Pages” admin page
- Disable HTML (Text) Tab in Post Editor
- How to remove “publish metabox” from each post type
- Change home-url in dashboard
- Editing the Backend Uploader
- Hide Pages on Edit Pages based on Capability (edit_others_pages)?
- Hide one admin from another admin
- How to add custom classes to admin list table default rows or columns?
- How to hide a specific part of dashboard for non-admin roles?
- Continuous Login Sessions For Super Admins Across Multi-Site Network of Sites
- using rewrites to secure login page
- Seems that admin_post_{action} does not executing
- If statement for admin page
- Customizing WordPress Admin – How to Change the Avatar size
- Create a WordPress administrator without access to back-end
- WordPress Brute Force Prevention
- How To Make Iris Color Picker Showed Up Over Form and Text?
- admin_enqueue_scripts not rending JS file correctly
- my checkbox is not saving it’s value
- How to break line / add to ADMIN menu
- Send admin to a different login than users?
- How much traffic is real traffic?
- Getting rid of menu items on a custom taxonomy
- Having problem creating local instance of wordpress site
- WordPress Plugin Admin Tab
- Parsing post->ID in included plugin file
- Gutenberg UI has changed
- How To Remove Import/Export Option From Tools?
- Different role for free and pro users in wordpress without using bbpress
- Enqueue script throws error in console
- How to sort post_meta in edit.php?
- Scripts are not called until I login from wordpress backend
- Link to all posts page?
- WP Logs me out after updating anything on dashboard
- Adding additional text fields and image upload to a Page?
- plugin to upload to youtube via wordpress [closed]
- How to fix: Clicking ‘Quick Edit’ link in Admin (edit.php) makes posts disappear?
- WordPress admin panel is blank
- Use the wordpress admin table
- deploying a standard build of wordpress in WHM/cPanel