Add the following to an mu-plugin (custom user role is so76666381
) (tested):
// Adjust admin queries to only show pages by current user if has custom role.
add_action( 'pre_get_posts', static function ( $query ) {
// Limit hiding pages only to admin queries.
if ( ! is_admin() ) {
return;
}
// Get post types from query.
$post_types = ( array ) $query->get( 'post_type', array() );
// If pages are not being queried, bail.
if ( ! in_array( 'page', $post_types ) ) {
return;
}
// Get user's current role(s).
$roles = wp_get_current_user()->roles;
// If user does not have custom role, bail.
if ( ! is_array( $roles ) || ! in_array( 'so76666381', $roles ) ) {
return;
}
// Limit results to those by current user with custom role.
$query->set( 'author', get_current_user_id() );
} );
Related Posts:
- Best way to manage a lot of pages in Wp Admin [closed]
- Can I allow certain people to add/edit pages within a parent?
- Add menu page issues (permissions & position)
- Is there any way to make myself an admin?
- Allow a page to be edited by a specific custom role
- How do I add custom fields to the “Edit page” admin screen?
- WordPress Plugin and other pages not opening
- The sidebar in wp-admin dashboard disappears when viewed on mobile screens in WordPress
- Custom post type – no layout section of Document tab, and no author choice
- How to delete page by deactivating plugin
- WordPress web pages keep getting deleted (moved into the trash) by themselves
- Run plugins only on certain pages
- (FES EDD) New vendor submission page is blank
- How to allow an editor to edit all WordPress blog posts but have the last say as administrator?
- Facebook Messager Plugin
- WooCommerce specifc variations for specific user role [closed]
- Polylang : Interverting languages after development [closed]
- WordPress plugin/theme or other wayout to create portable pages?
- 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
- php page not found for plugin options menu
- Is it possible make a back-end for WordPress with WordPress?
- Changing page URL and connect newsletter to MailChip
- Create tabs in admin options page from custom post type loop
- How to create user that has permission to create new sites on WordPress with multisite option enabled?
- Dynamic admin submenu
- WordPress page and plugin list using sql query
- Create page from plugin, but have it completely hidden
- Remove ‘Check Compatibility’ from Plugins menu
- How to add subcategories to the blogroll?
- Can a Plugin Override New User Default Role Type
- How do I write an inventory list plugin that creates dynamic details pages?
- Proper way to replace the_content only for pages created by custom plugin
- Display Custom Field Value on Admin Page Column
- Would Gutenberg be considered a PlugIn?
- I need help locating a URL that is on my site map, but that I can’t find in my WordPress dashboard
- Network activating; if ( !current_user_can( ‘manage_options’ ) ) locks me out…
- Cannot access my wp-admin after installing Gzip compression [closed]
- Show author on every sub-page
- Add sub menu page in your plugin
- can i limit editing specific custom fields to certain roles?
- Add user role to generated plugin
- Plugin settings won’t save changes
- Multisite – maximum number of users with specific role
- Full list of registered scripts or styles, but from an admin options page
- Understanding State in WordPress Multisites
- How to have sample page for each new register users in a membership website
- How to make multiple admin pages for one plugin?
- $wpdb update query in plugin only updating one column
- Allow only Admin role to access plugin settings/options page
- One sub site is slow while all others load fine, same theme & plugins [closed]
- How to allow Contributors to publish articles after approval
- Locked out of admin panel after installing HC Custom WP-Admin URL [closed]
- How can i force wp-admin to use 2-column dashboard layout? [closed]
- How to create a page with links to other pages that include image and excerpt?
- Odd /wp-admin/admin-ajax.php entries showing in Wassup
- Thesis 2 custom Page
- Making my plugin create a page?
- How can I modify page content in the admin panel?
- Add Content to Content()
- Display Plugin Panels Outside of Admin Areas
- How to display terms and conditions in post area?
- Simulating a wp page – wp page load sequence
- 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]
- WordPress Site is Broken, Cannot see wp-admin page [closed]
- Change the layout of action links under the plugin names
- How to create wordpress page that lets users create their own quiz? [closed]
- Multiple authors and readers restricted by role [closed]
- getting notifications about updates only in the “core” page
- How to remove a CPT Menu from the Root Admin only
- Custom Login page with custom redirects for each user?
- Huge number of 404 pages getting spawned
- Remove value from array within post meta ajax admin
- Is there a better way of handling AJAX requests in WordPress?
- Redirect Plugins.php to New Plugin Page
- Mowing site to another domain in simplest way
- Get post content from outside the loop with plugin shortcode usability
- Show WordPress Plugin Menu(Admin) To Editor
- Mutliple users editing single document in wordspress
- Show media-uploads to all users
- How to create plugin auto create page wordpress?
- Custom form not showing in correct place on page
- Change website directory safely to add a static page on startup
- Price comparison table based on Custom Post Type?
- Get access to WordPress when logged out
- Why are plugin settings not all nested in one place?
- Remove specific administrator’s capability
- Use jQuery Datepicker code from plugin
- Plugin permissions for Editor role
- Cannot access WP admin because plugin returns 204
- Install old version of plugin from admin panel?
- WordPress as heavily personalized content management portal, and somewhat like dropbox [closed]
- How to force load a page in plugin?
- How to dynamically change spots of text in custom page?
- How To Create A File Archive in WordPress?
- Role based permission edit for plugins
- Creating teams of users in WordPress