admin管理员组文章数量:1429455
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 11 Answer
Reset to default 0Yes, 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.)
本文标签: Display specific post categories to specific user roles
版权声明:本文标题:Display specific post categories to specific user roles 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745508605a2661364.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论