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.
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 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.