• I know there are hoards of plugins that allow you to limit access to content but for some reason, I am unable to find something that works for my case.

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    First you need to add a category field in the user’s profile which only admins can edit. Review the user-edit.php file for what action hooks are available for use in inserting added content to the profile screen.

    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.

    Thread Starter vagueillusion

    (@vagueillusion)

    @bcworkz Thanks for the help on this, much appreciated.

    Thought I would be able to tackle it with a plugin, alas, the code route it shall be.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Limit user front-end read access to posts from specific categories’ is closed to new replies.