0

I've added additional input fields to the user profiles with Advanced Custom Fields (for example "type of customer"). How is it possible to hide posts and categories for users with specific values within the custom fields? For example if a user has the customer type is set to “Cloud” they should only be able to see FAQ entries of the category “Cloud” and be permitted to access other categories. I only found plugins to hide posts based on the user role, but I am searching for a more flexible way, because type of customer won't be the only additional field.

1 Answer 1

0

You should check the pre_get_posts() filter hook.

2
  • Thank you for your suggestion. I'm still wondering, if this approach will completely lock out the user from certain categories or if they will still be accessible by their URLs and will still pop up in the search?
    – Mario
    Jun 21, 2022 at 8:44
  • @Mario they will be hidden. Feel free to check one of my posts to see it in action: kayart.dev/… Jun 21, 2022 at 22:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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