2

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
  • Yes, it is possible but not everything required is built in. Check out the available plugins, think though what you need in detail, get started, and come back with more specific questions about the actual code.
    – s_ha_dum
    Apr 12, 2013 at 14:06

1 Answer 1

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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.