administrator
isn’t a capability, it is a role, so the reason you get that error is because WordPress doesn’t recognizes the capability you gave.
If you look up the capabilities of the administrator role, you can see that the administrator is the only one with the capability manage_options
. This is the one you should use.
So what you can do is change the capability to manage_options
:
add_options_page( __( 'Theme Options' ), __( 'Theme Options' ), 'manage_options', __FILE__, function() {
echo 'Hello';
} );
Hope it helps!
Related Posts:
- How to enqueue JavaScripts in a plugin
- In Which Contexts are Plugins Responsible for Data Validation/Sanitization?
- Should Plugin Folders Include a Blank index.php File?
- What is the wordpress wp-includes folder for?
- WordPress Update Plugin Hook/Action? Since 3.9
- register_uninstall_hook() vs uninstall.php – which one is better way to handle plugin uninstallation script?
- Fatal error: Class ‘ms\WP_Query’ not found on plugin initialization [closed]
- Making a plugin file accessible via url rewrite?
- What is the correct way to build a widget using OOP
- How to implement bulk actions in my plugin?
- How to properly sanitize strings for update_option()
- Using AJAX in FrontEnd with WordPress Plugin Boilerplate (wppb.io)
- How do I implement a jQuery UI dialog modal in a WP plugin?
- WP Cron – Run Cron after evey 15 minutes at a specific time for the next three hours
- Which to use to execute code during the saving of a plugin settings page?
- How to Add Font Awesome Icons to WordPress Menus?
- Overwriting Core WordPress Functions with Plugins
- How do I handle multiple Submit buttons in plugin’s option page?
- add_meta_box() to Category Edit Screen?
- How to properly load text domain of custom mu plugin
- How to add quick edit and bulk edit fields to users admin section
- Whats the difference between blog_info(‘stylesheet_url’) difference get_stylesheet_uri()
- What does $_registered_pages do?
- Add Submenu Link in add_submenu_page That Opens in a New Window
- How to check if a stylesheet is already loaded?
- How do I change the initial quantity of a product in woocommerce?
- Redirect traffic to plugin
- How to insert data to a database table when the field is not yet created?
- Show special field when correct shipping is chosen
- Custom Taxonomy to dropdown box on adminside wordpress
- On cliking add new post redirect user to a custom page first
- How To Consistently Enforce Rewrite Rule in Plugin Development
- Create a new post using rest api and save featured image using an external image url
- wp.template() returns tags in Ajax response
- How to restrict access to image folder depending on whether product is purchased or not?
- Plugin directory says that my plugin it’s not availabe in Spanish, but it is
- Caching the_content calls
- How to hide or rename “X” and “x-child” references in website source?
- Using ob_get_content to get_search_form puts into infinite loop
- Can I add custom css to an mu-plugin?
- Change WooCommerce Email Header using custom plugin
- Bug: Post needs to be updated twice when adding action for save_post hook
- How to get the current page Title and Page URL in footer.php
- my own SVN for a plugin/theme
- How to enqueue scripts in right way in a plugin?
- How to add search form in main page body?
- Activate theme via plugin script?
- How can I add function calls to my plugin’s options.php default submit routine?
- WordPress Rest API with rest_do_request, possible race condition?
- Need help about understand api, wp, $ syntax in WordPress plugin script
- Secruity Questions on a timer
- How to rename the plugin PHP file without affecting existent users?
- Add location tag to wordpress posts
- Open tab on current day problem jQuery and WordPress
- Plugin working on my local installation but Cannot be activated online
- Is there a WordPress plugin to design WebGL? [closed]
- Load php file with jquery in single.php
- WordPress Page Reload Takes forever during theme development
- WP 3-way voting system: On to something! Please help!
- Why is the expected file not being deleted?
- How to determine which capability to use?
- How to add some basic inline CSS using existing plugin or theme?
- How does one update complex options?
- How to highlight a page in the page list (Admin Menu)?
- Forbidden Error in ajax call with wordpress
- How to use setAttributes outside of the edit function return
- WP plugin svn checkout 429 error “Too many requests”
- How do I add filter with woocommerce categories?
- WordPress Filesystem create CSS-File – get Shortcode ID for Name
- How to add admin.php to WP Admin Menu Link
- How to get access the ID of all posts of custom post type in Gutenberg editor
- Share functions between admin and frontend
- Editor Plugin – Breaks when toggling between Visual to Text
- Use admin-post to submit form data to external database
- Custom recurrence not working / Wp Cron event
- Single_template for a custom post type created from a plugin is returning an empty page
- How to retrieve custom profile fields associated with different users
- How to embed or integrated a custom WordPress Widget into the theme?
- Making adding info to an overlay bio easy for average user?
- Navigate to external link if last page or post in a category
- Confusing $tag specification for apply_filters call, in core options.php code
- create post of acf frontend not published and not trashed
- Is there a general way to get a themes primary colour?
- Why is ‘register_activation_hook’ undefined?
- Redirections the right way inside a plugin directory
- How to Register/Link to .js Files in WordPress Dynamicaly in Header.php
- Thumbnails for media Library images
- How to specify widget order or css name via script?
- How to view plugin ratings?
- get_categories exclusion issues
- Best Way to Inventory the Media Library of a 200+ Multisite Installation?
- upload script in plugin development [duplicate]
- Apply function on all action hooks?
- Getting Plugin directory and url
- how do I find out if a placed order was deleted or trashed? [closed]
- How react js and other Javascript Technologies works on WordPress plugin?
- Shortcode rendered in preview, but empty in post
- Trigger a JavaScript function based on the data fetched from Woo commerce hook
- Do Not Back Up? Is there any accepted way to tell backup and clone plugins to skip a certain file? [closed]
- get_the_tags($ID) is empty during publish_post callback