Is it possible somehow to hide Admin's pages & posts from dashboard so that other users will only view/list non-admin publications?
-
That's what user roles are for, install a plugin like "Members" or something to control the different capabilities per user role– JebbleCommented Jun 9, 2016 at 8:50
-
Do you use that plugin? Reliable?– RiccardoCommented Jun 9, 2016 at 8:52
-
Yes– JebbleCommented Jun 9, 2016 at 8:57
-
You may post your comment as a solution I will vote as the accepted solution– RiccardoCommented Jun 9, 2016 at 11:44
2 Answers
The WordPress admin area uses capabilities to determine which user role can see what pages etc. You can use custom written code or several plugins to control to capabilities by each user. I'd suggest using the Members plugin for some easy control.
-
The plugin doesn't allow configuring access to pages or posts by user or by category– RiccardoCommented Jun 10, 2016 at 8:19
-
Because WordPress doesn't have anything like that build in. I've provided you with a link to all the capabilities in WordPress, if you need other control inside the CMS you need to add custom functionality to the CMS which might be tricky. This is however also not what your actual question was :)– JebbleCommented Jun 10, 2016 at 9:02
-
About WP: there's no filter that may be hooked to the dashboard code and filter queries?– RiccardoCommented Jun 10, 2016 at 14:51
-
This seems working, with some adjustments.... wordpress.org/support/topic/…– RiccardoCommented Jun 10, 2016 at 15:02
Yes, it is possible to hide admin's pages and posts from the WordPress dashboard for other users. You can do it with custom code. Place this code in your theme's function.php file:
IMPORTANT: Make sure to leave the minus sign before the user id in the code below, that is what tells WordPress to exclude that user's post from the queries.
function wpb_hide_admin_posts_pre_get_posts($query) {
if (is_admin() && !current_user_can('administrator')) {
$query->set('author', '-1'); // Replace '1' with the admin's user ID. (the id of the user you want to EXCLUDE), leave the minus sign to exclude that user
}
}
add_action('pre_get_posts', 'wpb_hide_admin_posts_pre_get_posts');
Remember to replace 'author', '-1' with the actual user ID of the admin. You can find the user ID in the WordPress users section in the dashboard. This code checks if the current user is not an administrator and modifies the query to exclude posts/pages by the specified author (admin in this case).