最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Display specific post categories to specific user roles

programmeradmin2浏览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.

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.

Share Improve this question asked May 9, 2019 at 19:51 Enrica del RossoEnrica del Rosso 1
Add a comment  | 

1 Answer 1

Reset to default 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.)

发布评论

评论列表(0)

  1. 暂无评论