Apart from what I said in the comments — adding new roles should not be done on every (admin) init (here’s why), your code is actually good, but your post type is set to show under the custom admin menu named “Price Calculator” (see the 'show_in_menu' => 'my-menu'
in your post type arguments), so you’d want to either add the manage_options
capability to specific users like the one in question, or lower the capability required to access that menu, e.g.
// I changed the 3rd parameter from manage_options to edit_prices.
add_menu_page('My Page Title', 'Price Calculator', 'edit_prices', 'my-menu', 'show_price', 'dashicons-calculator', '13');
Related Posts:
- Allow member to have access to custom post type only. Permission to only edit their own posts
- Possible to hide Custom Post Type UI/Menu from specific User Roles?
- Allowing custom role access to custom post type in back end
- Restrict Contributors to view only their own custom post types?
- Why does my custom WP role need edit_posts to edit images?
- How to assign specific users the capability to edit specific pages / posts / custom post types
- Defining capabilities for custom post type
- Assign a Custom Role to a Custom Post?
- Creating custom user roles
- Can I make user role that can only access a certian content type?
- Create user role restricted to specific CPT
- How to set individual capabilities on a taxonomy? Or how to re-register an existing taxonomy?
- User roles – enable custom posts disable posts
- Add Capabilities to Custom Post Type after it has been created [duplicate]
- How to not allow custom roles to edit published custom post types?
- How to restrict specific post types from being read or added by specific user roles (eg. author)?
- How do I code access to the built-in UI of a CPT when it’s placed as submenu of another CPT that is protected by role?
- Custom user role not working as expected
- Which User Role for Custom Post Type Menu – wp_nav
- Prevent author role from editing all posts in custom post type?
- How to allow “Add New” capability of CPT when links to its UI are placed as a submenu?
- Custom Role can’t trash Custom Post Type
- Limit access to page depending on user level
- Why does current_user_can(‘edit_posts’) return true, but current_user_can(‘edit_post’, $post->ID) returns false?
- How to publish custom post type for custom role user and not “submit for review”?
- Prevent authors from creating new posts of specific custom-post-type
- Registration and Custom Post Types – How to synchronize information?
- Gutenberg Featured-Image-panel missing when user with custom role edits Custom Post Type
- Limit users by custom taxonomy and user roles
- Allow Administrator role access to custom capabilities [duplicate]
- using add_role function to make some users to create a selected type post
- How to enable a custom post type to custom user role in WordPress
- Cannot attach media when capabilities added to custom post type
- After adding add_role to functions.php and creating a user, can not login into admin
- Restrict user to only one custom post type
- How to restrict CPT post’s fronted view only for specific user roles?
- current_user_can() return FALSE but debugging says TRUE
- Role capability delete multiple post type posts doesn’t work
- How to allow a custom user role to create, edit, delete a specific custom post type only?
- Display content based on a users login
- Define new user capability for custom post types?
- Custom post types as sub menu pages and role capabilities issue
- Hiding posts by other users and non-logged in
- WordPress multiple custom post types capability conflict in a single menu
- Only view/edit/delete CPT made by users with the same role
- How to set individual capability of post type in individual category
- WordPress comments_open for specific user role or post type
- Restrict Access to Posts based on Custom User and Post Meta Data
- I want to create custom post in which user can share files like PDF & DOCx
- WooCommerce Customer Role Delete Custom Post Type
- Allow Contributor to edit but not update a published post
- Disable user from updating certain posts
- Edit the author of custom post type
- Access to CPT but not to ‘post’ post type
- Allow add new post access to custom post but not wp post for some role
- Deny user access to edit post while allow him to edit custom post type
- Allow user to only access custom post type
- How to show featured image block in custom post type for Author?
- WordPress custom post type capabilities issue
- disable quickedit for specific custom post type user role
- Custom User role not working with custom post type
- Building Forums with Custom Post Types
- Role capabilities issue
- Unable to edit categories in custom post type
- Prevent user from editing others posts
- Roles and Capabilities in Custom Post Types
- How do I “trash” a custom post type post while logged in as Admin
- How to fix the Post Preview Button (CPT & map_meta_cap)
- Restrict Custom Post Type per role in Dashboard
- Restrict access to custom post type based on its taxonomy terms
- While creating a post, can I restrict the authors in the dropdown list based on their user role?
- Clone wp-admin/users.php (Users Admin Page)
- Why “Mine” is the default view when adding ‘capability_type’ in register_post_type
- Create relationship between custom post types and users
- Restrict admin pages for specific user role
- Conditional editing CPT – using editor’s role and author’s usermeta
- How to only display all posts to a custom User Role?
- Remove plugin settings from post creation page for a user role
- Allowing custom role user to edit post assigned to them but don’t let them create new custom type post
- I want to show post details based on roles user login
- Multiple useres editing specified content
- Instructor can view, edit, delete only theirs courses
- How do you make a custom post type invisible for subscribers
- Front End users account with lots of user Roles (not Woocommerce)
- Capibilities of CPT WordPress
- How can I remove “Add new” button on custom post type
- Capabilities and mapping required for a role to be able to edit other’s posts of a custom type, BUT only be able to edit their own blog posts
- Custom user roles
- Editor role isn’t seeing specific post type posts with only post_type parameter
- Weird capabilities / roles behavior
- Control what custom posts a user can see
- Custom Post Type only display items created by user
- Prevent author role from editing others posts
- Default taxonomy ‘post_tag’ added to CPT managing by custom role : nothing in the metabox
- Custom taxonomy archive is visible to only subscibed users
- Custom role, capabilities, and post type: preview button wrecks things
- Custom role can’t create permalink
- empty dashboard for custom role
- Read-Only custom post type
- Custom Plugin w/ Custom Post Types – Custom Posts Are Showing at all Privilege Levels – Is this possible to adjust?