• Hi!

    Is there a recommended approach for filtering out products that have a specific access group?

    Scenario is simple: One user belongs to 3 groups and this user would like to be able to select which group products they see.

    Wonder if there’s already some out of the box support for query parameters that work similar to the product attribute/category filters? E.g ?groups-read[]=2

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Kento

    (@proaktion)

    Hi,

    Good question, thanks for asking!

    Currently Groups does not support a query parameter that you could use directly, but that is something we might want to consider adding support for.

    If you would like to try it out conceptually, you could implement a hook on the posts_where filter, check the presence of a groups-read parameter in the request and add a constraint to the query that limits the results to posts that are restricted to matching groups.

    If you are going to do that, please share your impressions, it would be useful while we consider adding this as a function in Groups core.

    Cheers!

    Plugin Author Kento

    (@proaktion)

    PS link to version 3.4.2’s posts_where filter used to restrict access which you might find useful while implementing the suggestion https://github.com/itthinx/groups/blob/fe4c93500470b381c1718dd0b937ea2cfb42e377/lib/access/class-groups-post-access.php#L250

    Thread Starter Limegrow

    (@limegrow)

    Hi!

    Thank you! Seems rather easy and we will try it out in the upcoming sprint and report back how it works. ??

    Cheers!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.