I’m building a multi-user WordPress environment where users are grouped by specific privileges, primarily concerning access to the dashboard. The goal is to restrict users from editing pages they shouldn’t touch.
While role and capability plugins like Members handle permissions well, they don’t allow fine-grained control over which pages appear in the dashboard. Most available plugins focus on hiding posts/pages from the public site, and those few that affect the backend – like Manage Your Posts – are limited to showing only an author’s own posts, which doesn’t apply when editors need access to others’ content.
function edit_page_per_capability($query) { if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/edit-pages.php' ) !== false ) { if (current_user_can('organizer')) { $query->set('post__in', array(184,186) ); } elseif ( current_user_can( 'instructor' ) ) { $query->set('page_id', '186'); } elseif ( current_user_can( 'office' ) ) { $query->set('page_id', '8'); } } } add_filter('pre_get_posts','edit_page_per_capability');
By modifying the core function from Manage Your Posts, I created a filter that limits the Pages list in the dashboard to only those allowed for each user group. Capabilities are still managed via Members, and the filtering uses page IDs mapped to each group’s permissions.
To make this work with WordPress 3.0+, update the admin URL to /wp-admin/edit.php?post_type=page
. For better readability, consider using query_posts()
with slugs instead of numeric IDs.
To implement, drop the code into your theme’s functions.php
file and tailor it to your access structure.
One reply on “Hide Pages from WordPress Dashboard Editor View by User Capability”
It’s just what a I looking for a long time. I used the plugin and it’s works for me! Thanks!