The only prerequisite for current_user_can()
is an existing wp_get_current_user()
. The latter is defined in pluggable.php
, so you can use it after plugins_loaded
.
The _doing_it_wrong()
call you are citing in your question is wrong for itself. My guess is that you took that from BuddyPress or bbPress. Both are running into a recursion if they don’t wait that long. There are other, better ways to prevent the recursion.
In some cases, like changing the locale, you have to access the current user object earlier, so waiting for after_setup_theme
isn’t even an option.
Related Posts:
- Disable posts, only allow to edit existing pages, not create new ones (create_posts)
- Multiple Authors on Single Post
- Remove menu items from admin page and limit capabilities
- Prevent all users from editing posts except admins using hooks
- What action should I hook into when adding roles and capabilities?
- Allow Contributor to change the author of his own post?
- What’s the difference between Role and Meta capabilities; When to use map_meta_cap() filter
- Add Custom User Capabilities Before or After the Custom User Role has Been Added?
- add_menu_page permissions – what am I doing wrong?
- How can I grant capabilities directly to users (not roles) in wp-admin?
- How to get all capabilities of an existing user role
- What exactly is WordPress?
- Menu capability in WordPress
- Does the “promote_users” capability allow someone to create a new admin account?
- current_user_can( ‘edit_post’, $post_id ) does not work for contributer but for administrator
- Add user capability and check against it
- Listing all capabilities in dropdown is returning boolean
- Add Media Upload Capabilities Needed for Custom Role for non-Posts
- add_cap only adding the first two in array
- Is there a simple way to manage capabilities per user?
- How can I prevent a writer from being able to edit an article that has been scheduled?
- Check whether user can delete a given post
- How can I set status=’publish’ for all featured images?
- How to check if a role has a specific capability
- How to remove sticky post capability for a specific user role?
- How can I have different groups of editors only allowed to edit certain parent+subpages?
- Allow unfiltered HTML in titles for low level users?
- Allow users to set a post author
- Unify the roles and caps?
- current_user_can Not Always Working Properly
- current_user_can capabilities in the admin not working as expected
- Remove wordpress author’s capability to moderate comments on their own posts
- Filter list of rules based on a capability
- Using author_can() on custom post types in WordPress
- Can you set a role as author?
- How to show a admin bar menu item only to users with certain capabilities?
- Are User Levels Still Currently Used?
- Restricted user capabilities cannot add image
- User capability per post
- Roles for Custom Post Types
- How come I see a manage_categories capability but not a manage_tags capability for any users?
- Theme option editing capability problems
- Allow Contributor to edit published post and filter by page id
- Applying roles to an admin sub-menu (eg Appearance -> Menus)
- read_post meta capability for anonymous users
- Admin cannot publish
- You do not have sufficient permissions to access this page on a submenu
- Usage of current_user_can()
- Is it wise not to use only meta capabilities for certain basic post types?
- Remove capability from specific user
- What capabilities are assigned to unauthenticated users?
- Capabilities Not Changing
- Assign multiple roles , overlapping capabilities
- Administrator role capabilities
- Hiding custom theme functionality using capabilities
- How to get all capabilities
- User Capabilities are not available in WP REST permission callback?
- WordPress remove capability post ,media completely for custom role
- Add capability to “Editor” role to be able to view all users attachments
- Why cannot author edit pages?
- Add capability to a role , so user is only able to view his own posts
- Plugin page and capabilities
- Unable to access custom plugin backend
- How to let a role handle media without post permissions
- how to change capability required to view an admin page? [duplicate]
- insufficient permissions; coding an action for plugin governed by custom capability
- How to hide plugin options for editors via functions.php
- Why “Mine” is the default view when adding ‘capability_type’ in register_post_type
- Set edit capability based on ACF relationship
- See which user role / capability is needed to use a plugin
- How can restrict certain users from delete a category but can view only in wordpress?
- Delete admin edit/delete links in users list wordpress admin
- Create a Capability category to group a few custom Capabilities
- Capability to edit post slugs
- admin can not change author profile picture
- Remove Custom Capability
- Force “submit for review” on update?
- Changing capability type without altering plugin
- Can’t create new Pods pages
- Is there a way of retrieving the core WP capabilities?
- Pricing Tables admin page capability
- Best Roles and Capability on a site with review features using a front end custom post
- Not able to give editors acess to new admin menu item
- Manage Roles and Capabilities on Multi-site
- current_user_can() returning true for capability when the user and role do not have the capability
- How might I enable a user to view Draft pages from a different Author, without the ability to edit?
- Can’t upload media, permissions are correct
- What do unfiltered_html and unfiltered_upload actually filter?
- What capability allows someone to change a page’s/post’s author?
- How can I control multiple editing of wordpress posts?
- edit_comment capability for subscriber
- Plugins will only be installed with 777 on folder. Solution?
- Custom post types as sub menu pages and role capabilities issue
- Rest api return all users (even without content) to all users
- Why is the ‘Gutenberg’ Plugin generating an ‘Inconsistent File Permissions’ error when other Plugins, with the same permissions, do not?
- Admin user lacks admin permissions after hack and can’t reinstate
- Disabled delete_others_posts if post is from admin
- fine-grained capabilities for user related capabilities
- Making plugin to use different table prefix cause permission problem
- edit slider plugin capability for custom_role