I have a site that needs to only allow people who are logged in and have at least one of 3 possible roles to have access to the pages of the site. I'm not new to programming, but am new to both php and web development. I would prefer an "in-house" solution instead of a plugin, but at this point I will take what I can get.

So how it would ideally work was that a user from our main site could come to the secondary site (which are linked om terms of user accounts) and they would hit the login page. They should not have access to any of the other pages until they login. After they login if they have a specific role ("Instructor", "Admin", or "Super Admin") they can access the rest of the site. If they don't have one of those roles they should always be redirected to a page that tells them they don't have access to this site (ie /no-access).

Is there a way or a plugin to let me do this? Thanks

Edit: Since this might need more narrow of a scope...

How do I restrict access to the webpages based on a users role? I know there's a way to do it with

is_user_logged_in() && current_user_can(Capabilities)

and custom roles with specific capabilities, is there a way to say

  • It's probably possible. WordPress has native support for role-based management, and you can extend the roles to include other roles than the WP defaults. However, you're going to have to narrow down the scope of your question here. As it stands, it sounds like you need a developer to build a solution for you, not an answer to a specific coding question. – Pat J Feb 23 at 22:12
  • Regarding the role or capability checking, you may find this older Q&A relevant, wordpress.stackexchange.com/questions/5047/… – Antti Koskinen Mar 9 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.