Custom restiction

Posted in

Hi, I’m trying to figure out if it’s possible to create this rule.

Hide a specific post type if:
– – if the post is from the current year
– – the user is not part of the “jury” group
– – user is not the author of the post
– – post taxonomy is “open”

do you think it is doable?
thanks in advance

One Response to Custom restiction

  1. George February 6, 2023 at 6:14 pm #

    Hi Emanuele,

    Welcome back to our support forum.

    For a case like this, I think you should better use pre_get_posts hook and adjust the query parameters, fetching only those posts that don’t match the parameters you choose.
    Please have a look at the definition and supported parameters here:
    https://developer.wordpress.org/reference/hooks/pre_get_posts/

    As for the conditional for the user-group check, you can have a look at the example – Does the current user belong to the Foobar group? – located in the Examples section of Groups documentation.

    Kind regards
    George

We use cookies to optimize your experience on our site and assume you're OK with that if you stay.
OK, hide this message.

Affiliates · Contact · Jobs · Terms & Conditions · Privacy Policy · Documentation · Downloads · Useful Plugins · My Account

Share