if( is_admin() ) {
add_filter( 'init', 'custom_restrict_pages_from_admin' );
}
function custom_restrict_pages_from_admin() {
global $pagenow;
$arr = array(
'update-core.php',
'edit.php'
);
if( custom_check_user_roles() && in_array( $pagenow , $arr ) ) {
//echo some custom messages or call the functions
} else {
echo 'This page has restricted access to specific roles';
wp_die();
}
}
function custom_check_user_roles() {
//restrict pages by user role
if( current_user_can( 'administrator' ) || current_user_can( 'editor' ) )
return true;
else {
echo 'Not allowed!';
wp_die();
}
}
Related Posts:
- Limit access to posts/pages by user roles
- How can I change plugin to give access to editor user role?
- How to make this custom capability work? [duplicate]
- How to create different views for different user roles?
- How to show private pages based on a user’s role?
- How do I restrict a second admin certain access?
- Custom User Role
- How to give different user access to different people?
- How to enable suggested edits?
- How to check if user is in back end?
- How to prevent a post from being deleted?
- Deactivate plugin for a specific user group
- Publish author posts only with editor approval?
- How can I modify the Capability needed to access a plugin’s options?
- WordPress Capabilities: edit_user vs edit_users
- Disable plugins for a specific user role
- User profiles and object associations
- How to assign user a role if none is present when logging in
- Restrict access and display for categories
- Specific post user permissions
- How can I let users to access plugin functions based on roles?
- Dynamic homepage according to user role
- Restricting users to a specific front end page [closed]
- Remove Adminstrator Hyperlink from a user having role to add and see users
- Enable comments for post with comments meta box removed
- Restrict backend but allow to use post.php?action=delete&post=POSTID from front-end
- Give editors access to particular plugin – turn “admin.php” into “edit.php”
- wordpress custom login successful redirect hook
- 403 Forbidden – You don’t have permission to access /wp-admin/admin-ajax.php on this server
- Advanced Custom Fields/User Role Editor – how to hide ACF for certain users?
- Update User Role
- Getting user roles in plugin files
- How to achieve certain page (url) accessible to certain users
- How to make a customize role and view a specific plugins base on that role?
- Hook to plugins admin settings
- How to create user groups and allow custom posts and plugin modify/access to specific group?
- how to give a user a role?
- Filter custom posts based on the user role of author
- Redirection of users away from wp-admin (but not administrators)
- Custom post type – no layout section of Document tab, and no author choice
- User Session and Stored Cookies not get removed
- How to allow an editor to edit all WordPress blog posts but have the last say as administrator?
- How to create restrict content to users (by user, not by role)
- How to set add question capability for author role in wp pro quiz plugin
- Problem with the Loop – want to limit the access to three free articles
- How to create user that has permission to create new sites on WordPress with multisite option enabled?
- Lock access to plugin options
- Can I allow certain people to add/edit pages within a parent?
- can i limit editing specific custom fields to certain roles?
- Is there a plugin that lets users request an account on the site? [closed]
- Add user role to generated plugin
- Is there any way to make myself an admin?
- Understanding State in WordPress Multisites
- Allow only Admin role to access plugin settings/options page
- How to allow Contributors to publish articles after approval
- Is there a plugin for WordPress for creating ‘Accounts’ where all users who belong to that Account can only see Account data? [closed]
- Custom shortcode for displaying user based on a role parameter
- How I can change the required capability for an admin menu without editing the plugin file?
- Add User Role: Pre-saved in User-Meta [SOLVED]
- Multiple authors and readers restricted by role [closed]
- Custom Login page with custom redirects for each user?
- Show WordPress Plugin Menu(Admin) To Editor
- Mutliple users editing single document in wordspress
- Show media-uploads to all users
- Give access of horizontal scroling plugin to user role editor
- Plugin permissions for Editor role
- How To Create A File Archive in WordPress?
- Role based permission edit for plugins
- Specific plugin for custom user information access? [closed]
- Plugin privelages for “editors”
- Plugin access and Roles
- Plugin Hook When New Author Added
- Adding plugin editing capability for Author
- Show an admin menu item in Editor role
- Plugin or ways to limit number of users logging in the website,
- Allow a particular user to access a particular plugin?
- How do I allow a user to purchase an expiring passcode to access part of my website, from my online store, similar to pay-per-view?
- how to create user profile pages and display them based on users roles
- Allow editor user to full permission to access plugin settings
- Blank dashboard with no access
- Allow a page to be edited by a specific custom role
- Public WP website with one area just for members
- How to block access to certain WordPress pages using a snippet
- How can I disable access to plugin settings in wp admin for other roles
- Remove dashboard links from wordpress
- User / membership Plugin [closed]
- Why user profile update creates Additional Capabilities
- Overwrite user role
- Run only on plug-in activation instead of wp_head
- Allow non-admin users to access plug-in
- Defined user role to access plugin’s pages
- Restrict my pages from public
- Want to add post to user dashboard
- Allow a role to edit one specific plugin
- WordPress Role Capability Restriction
- Sync roles across several plugins
- registration plugin [closed]
- How to give access to the particular page in wordpress for specific username/email NOT roles [closed]
- edit slider plugin capability for custom_role
- How to have certain products show for only certain users (Not roles)