0

I'm creating a learning website on WordPress. I've already created different user roles based on the company's roles (eg. Agents, Managers) but I want every role to only be able to see specific posts with a specific category. So for example an agent after logging will only see 'agent'-category posts and every other post categories won't display. Basically a customized experience. These users will be 'subscriber'-like users, so will be only able to read and leave a comment.

Is it possible? Can anyone help me with a good code?

Thanks a lot.

0

Yes, this is all possible, but your question is a bit too broad for this site. :)

You may want to look into membership plugins which already have these types of capabilities, or you can build your own. If you choose to build your own, it's easiest to create a custom post type for each role. So for example, you'll have an "agent" CPT and a "manager" CPT, and you'll use map_meta_cap to create custom capabilities for those post types. This way, you can create your own "agent" role and "manager" role, and each one will only be able to read that specific post type. And since all other users do not have "read" capability for that post type, they won't be able to read (or comment). (You'll also need to set up your theme in a way that checks whether the user is logged in - if not, you can either display a message encouraging them to register, or else redirect them straight to the login form. That way outsiders won't be able to read or comment on these posts either.)

Your Answer

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

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