WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to create specific sections of my site which should only allow certain users to access them.

So basically, I'll be having a staff section - if the user is a staff member, they'll see a link to the section and obviously be able to see all the info there.

I've looked into a couple of things, namely adding user roles but they all seem to have a set list of capabilities that I can set. There isn't anything that I can find that will allow me to restrict users access to certain parts of the site.

I don't mind using plugins or anything like that - any suggestions would be welcome.

share|improve this question
up vote 1 down vote accepted

You could create a new role, say staff, and add the users you want to that specific role. Then link that role a new capability of your choice, e.g. access_staff.

Now you have a new role with a new capability, so all you need to do to restrict the access to any part of the site is add this piece of code:

if ( is_user_logged_in() && current_user_can( 'access_staff' ) ) {
    // Section
} else {
    // Let them know they don't have enough privileges or...
    wp_redirect( wp_login_url( get_permalink() ) ); // Send them to the login page 
share|improve this answer

If your needs are simple, the Log Me In custom login plugin might do. You can control what user roles have access to the dashboard and select a custom set of links displayed on the front end to the user when logged in. If this isn't sufficient there are lots of membership plugins available.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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