With you current_user_can call everything is just fine. The problem lies elsewhere…
If you’ll take a look at Roles and Capabilities, you’ll see that there is no capability like edit_post. So your code is working correctly – admin can’t edit_post, because there is no such capability (unless it’s a custom capability registered by your code elsewhere).
But my gut tells me that you wanted to check if current user can edit_posts 😉
Related Posts:
- What action should I hook into when adding roles and capabilities?
- What is valid timing of using current_user_can() and related functions?
- 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
- How can I grant capabilities directly to users (not roles) in wp-admin?
- Disable posts, only allow to edit existing pages, not create new ones (create_posts)
- 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
- 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
- Multiple Authors on Single Post
- Allow unfiltered HTML in titles for low level users?
- Allow users to set a post author
- Unify the roles and caps?
- Remove menu items from admin page and limit capabilities
- Filter list of rules based on a capability
- Using author_can() on custom post types in WordPress
- How to show a admin bar menu item only to users with certain capabilities?
- Restricted user capabilities cannot add image
- User capability per post
- 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
- 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
- How to get all capabilities
- Prevent all users from editing posts except admins using hooks
- 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
- how to change capability required to view an admin page? [duplicate]
- 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
- 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
- Force logout when role is changed
- Reset default roles and capabilities
- WordPress SEO by Yoast: Hide Meta Boxes in Posts for Non-admins
- How to assign multiple roles for capabilities array withini register_taxonomy function?
- The ‘user_has_cap’ hook seems to take two page loads to trigger
- Create user role restricted to specific CPT
- Prevent Admin user to edit/see super admin from users list
- User role permissions based on taxonomies
- Custom Post Type Tag Capabilities Not Working
- Giving permission to anyone (non-users as well) with a password to edit a post, possible?
- Permit users with author role to edit a custom post type
- add_cap not working
- “Submit for review” for updates on existing posts
- “edit_published_posts” and “edit_other_post” issue
- Adding post tags without capability edit_posts
- Purpose of Adding Capability to Role But Not Grant?
- Organize WordPress site, so it can maintain with huge database
- Create a User Role with permissions to only upload files to the media library?
- How to get a users list by who created them?
- WordPress custom post type capabilities issue
- How to keep the capability of users and disable Gutenberg editor in WordPress?
- How to write conditions based on user capabilities not on user role?
- Custom Post Type – after disable ‘Add New’, I can’t edit and delete post
- Wp custom post custom capability not working together
- Privilege to recover trashed posts
- how do I add role and capability after I create a new user
- Completely remove ability to create users?
- How to hide plugin options for editors via functions.php
- How can I restrict changing the max nested comment levels option to super admins?
- Adding plugin editing capability for Author
- Why can my subscribers create new posts for review?
- REST API – Allow /users endpoint depending on a custom capability
- Why “Mine” is the default view when adding ‘capability_type’ in register_post_type
- Custom Post Type Capabilities Singular/Plural
- Role and Capabilities: How do I allow user role to access theme options without enabling ‘manage_options’?
- Multiple useres editing specified content
- Removing add new pages form editor role
- Capibilities of CPT WordPress
- A different role for each site in a multisite
- get user role value as a string from wp usermeta table into custom script
- Need to create admin user without capability to create user
- Understanding capabilities parameter in register_post_type()
- Why is user_can_access_admin_page() an undefined function?