Does WordPress have fine-grained view permissions?

I am considering using WordPress for a number of users in overlapping groups, e.g. a user may be in group A and group B, or only group A.

Is it possible to use WordPress to limit access to particular Pages. e.g. Only members of group B can view this page, only members of groups A and C can view that page.

Would this permission extend to the menu item linking to the page? (e.g. if user can’t view page, they can’t see the menu tab/menu item)

1 Answer
1

That’s an interesting question. You could probably Create Custom Roles and use Roles and Capabilities ( codex.wordpress[dot]org/Roles_and_Capabilities ) to your advantage.

You might also be able to add Custom Fields To each User ( wpengineer[dot]com/2173/custom-fields-wordpress-user-profile ) that could help you achieve this goal.

This bit of code below might be helpful as you research. Entering this code in your functions.php file you can restrict a user with a specified capability from accessing the admin area. As you can see below using current_user_can(‘capability’) you can create a function or use an existing function. Then all you need to do is hook into the action that you need.

    /*********************  Restrict Admin Area to only Admins **********************/
function restrict_admin()
{
    if ( ! current_user_can( 'manage_options' ) ) {
                wp_redirect( site_url() );
                exit;
    }
}
add_action( 'admin_init', 'restrict_admin', 1 );

Good luck!

Leave a Comment