All users on my site will be registered as subscribers, what I need to be able to do is to go to each users’ profile and select a category/s.
When updated the user should only be able to read posts on the front-end from the category/s that was selected.
Anyone know of a way I can achieve this.
]]>Use the ‘edit_user_profile_update’ action to save the submitted data in user meta. Only do so when the current user is an admin.
Use the “pre_get_posts” action to alter post queries from subscribers so that posts returned have the category assigned in their user meta. Only alter the main query when ! is_admin()
. I’m assuming your theme uses WP_Query to get posts, most do. If the theme uses an alternative way of getting posts, pre_get_posts would be ineffective.
Thought I would be able to tackle it with a plugin, alas, the code route it shall be.
]]>