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 text tab on WordPress text-editor
- Allowing Custom Capability to Manage Plugin Options
- 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
- Woocommerce: change user role after completing order
- 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
- Understanding State in WordPress Multisites
- Allow only Admin role to access plugin settings/options page
- How to allow Contributors to publish articles after approval
- Timed content and flagging content as viewed by user?
- 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
- Remove specific administrator’s capability
- Plugin permissions for Editor role
- How To Create A File Archive in WordPress?
- Role based permission edit for plugins
- Creating teams of users in WordPress
- WordPress Membership Plugin Advice [closed]
- How to hide plugin options for editors via functions.php
- 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
- implement custom roles in custom plugin
- Plugin or ways to limit number of users logging in the website,
- Allow a particular user to access a particular plugin?
- See which user role / capability is needed to use a plugin
- How to generate expiring URL of the page?
- Need help with Task assigning and rewarding as currency which withdrawable
- 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
- ERROR message: “The site is experiencing technical difficulties. Please check your site admin email inbox for instructions.”
- 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
- Disable plugin for administrator
- User / membership Plugin [closed]
- Restrict role to use a plugin
- Why user profile update creates Additional Capabilities
- Wordress admin page is fetching error You do not have sufficient permissions to access this page.
- 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
- Different email notifications (about pending posts) to different users
- Restrict my pages from public
- Hide some portion on single.php base on author
- Plugin (smart archives reloaded) crashed site / no access on admin panel
- Want to add post to user dashboard
- Allow a role to edit one specific plugin
- How to block external download link access if visitor not referred from WP?
- WordPress Role Capability Restriction
- Zigconnect Plugin: Allowing editors to remove connections
- 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]
- How to disable plugin capability : “create new category”
- edit slider plugin capability for custom_role
- How to have certain products show for only certain users (Not roles)
- Show the author only own types of publications. (JetEngine, Elementor)
- Show different page depending on user role
- coauthors_plus_edit_authors to display metabox based on author caps
- How to create WordPress login for different users, with different roles?
- Show only those pages that are created by the specific logged in user in WordPress