The registered capabilities (and the other features) for registered post types are not saved in the database, but in a global variable, $wp_post_types
.
Being a global variable, editing it is easy. However you’ll also need to manually remove the menu item, otherwise authors and contributors will be able to see it even if they cannot create/edit posts.
In following function I’ll set the capabilities for post
post type coping ones from page
post type.
add_action('init', 'restrict_posts', 1); // registration run on init with priority 0
add_action('admin_menu', 'remove_post_from_menu', 1);
function restrict_posts() {
global $wp_post_types;
$wp_post_types['post']->cap = clone $wp_post_types['page']->cap;
}
function remove_post_from_menu() {
if ( current_user_can('edit_others_pages') ) return;
remove_menu_page('edit.php');
}
Related Posts:
- How to restrict attachment download to a specific user?
- Using JWT to authenticate a user with an external system?
- Allow anonymous user to access Themes Customizer
- Is there an existing capability to allow editing of only pre-existing pages? If not, a good way to implement this?
- How to make user inactive by default while registering?
- How to set privilege to wordpress subscriber for private page
- authenticate user without password from email activation link [duplicate]
- User Access Manager plugin
- How can we Restrict to access a certain wordpress page to all ip address except some which we allow
- Restrict post to user_id
- add_option_page capability behaving strange
- Access denied on Published Pages but not on WordPress /wp-admin/
- Allow non logged users to visit only login page and password reset page
- How can I allow users to make groupings of posts
- Is user listing on wordpress private?
- How to restrict logged user to view only certain pages?
- Limit post display to post authors and create an exception for specific pages
- How to “Global Ignore” / “Hell Ban” someone, restrict post visibility to the author only?
- Conditional menu for registerd users/guests (Genesis framework)
- How can I create an upload page for (and only visible to) specific users?
- remove wp admin menu by customer user role
- Custom Roles for access to specific term(s)
- Why: sticky front page code, shows latest non-sticky on logged-in front page
- Access denied error when logged in as admin
- Disable all admin UI access to authors (except to custom post type add, edit and modify)
- Hide all pages except landing page
- How to restrict access to a page?
- How can I change access permissions across many pages?
- How do I get the access type in WordPress?
- Profiles site with access levels
- User access control in sidebar archive and categorires
- Plugins that restrict access based on user group/roles
- Restrict access for wp-admin panel
- Specify the level of access to different pages at the time of user creation
- When add analytics script, wordpress user login not working
- Hide WordPress “wp-admin” dashboard to User IDS
- I cannot access but but wp-admin works normally
- about visibility in wordpress regarding of roles
- Can access main URL and Dashboard but not any posts or pages [closed]
- How to List only the users created by a particular user
- How to enable to the user send content and save as draft entry?
- How to give members access to their own protected page?
- Use WordPress engine for user registration and management
- How to make future posts visible to selected visitors without login
- Add existing user as administrator
- Split post edit screen into sub-edit screens for users, is this good or bad, and is it possible?
- Suggestions for allowing basic users to view their own posts?
- How to restrict posts only from a certain category
- Two users attempt to modify a page
- How to get all capabilities of an existing user role
- Add user capability and check against it
- how to add custom user capabilities using add_user_meta or something else?
- Restrict acceess of a page in backend
- How to display only logged in user’s post comments in comments area
- Issue with front-end ajax, getting a 302 redirect when accessing wp-admin/admin-ajax.php
- Allow Users Access to Custom Post Type Only
- How can I allow access to two user accounts using one login?
- Can’t access WordPress as an admin – but I can log in as a user!
- Managing Users and Creating Groups [closed]
- How to restrict CPT post’s fronted view only for specific user roles?
- How to protect post attachments related to a custom post type, from non-logged in users, on 1 subsite of a multisite installation?
- Restrict access of admin uploads to certain logged-in users?
- Multisite registration problem [closed]
- Only Allow Front End Access
- Reset Password policy
- How to add a private user page populated from sql?
- Disable comments for a user? [closed]
- Lost administrator privileges and can’t find a fix
- Limit a user to have access to only specified pages?
- Check if user registered more than a month ago
- How to change footer or for different kinds of users in wordpress?
- Add access control origin header information across multisite
- How can I stop access of unregistered user in wp-content/uploads directory without using .htaccess file?
- Grant a person permission to moderate all comments on a blog without giving them the ability to edit other peoples post
- How can I create a custom plugin that allows anonymous users to signup without registering?
- Auto log in hook is requiring a page refresh
- Make (custom) post type accessible only by custom query
- How to Find The Email of a WP Admin Account
- Using WP for user management
- Restrict the list of parent pages to only those which are created by current user
- redirect if shortcode exists
- Can I Create a Second Admin Level User Role?
- Give access of horizontal scroling plugin to user role editor
- Need to block user role from accessing bbPress all together
- Allowing WordPress.org/com accounts on a self-hosted install
- How to add a custom filter (by coding) before access one wordpress page ? And where to call the custom filter?
- Plugin or ways to limit number of users logging in the website,
- How to add a “base” filter for all posts visible to visitors on the site?
- How to create different views for different user roles?
- How to show private pages based on a user’s role?
- Restrict user to terms in a custom taxonomy registered for both posts and users
- Custom User Role: Can Edit Own Page, Cannot Create New
- How to lock WordPress front-end with login and password?
- How to block direct access to files upload in edd folder
- Plugin (smart archives reloaded) crashed site / no access on admin panel
- Allowing access to certain WordPress created pages or posts with htaccess / htpasswd
- view and update form only for registered users
- How to post data to a word press site in case of a mobile app
- You do not have permission to access this document on form submit
- After Upgrade: $user becomes unknown (id: 0) after successful login?