Your cart is currently empty!
Deny Access Based On Group
—
by
If a user belongs to a group, I would like to restrict them from all posts associated with that group.
Essentially, this is an inverse of the standard functionality. Instead of Read, I need a Cannot Read.
How can I accomplish this?
Posted in Groups Restrict Categories
Comments
9 responses to “Deny Access Based On Group”
Hey Brad,
FYI, we have updated the addon and also added support for HPOS. I would recommend you to remove your existing version and install the new one.
Also, the hook
add_filter( ‘groups_wc_not_purchasable_filter_visibility’, ‘my_groups_wc_not_purchasable_filter_visibility’, 10, 3 );
function my_groups_wc_not_purchasable_filter_visibility( $filter_visibility, $visible, $product_id ) {
return true;
}
must return true for the products to be not visible.
Kind regards,
George
Hey Brad,
Let me have a look at the addon and I’ll follow-up here.
Cheers
Thank you for the reply.
I’d like this functionality for a specific group. The rest I need to operate as normal.
It needs to affect more than just the post content. I am applying it to WooCommerce products.
So, I’m looking for to function like this:
In these cases group B will be the negative/deny group.
Scenario 1
– User is in group A
– Product is associated with group A
– User CAN see product in the listings, search, and access the product directly.
Scenario 2
– User is in group A and in group B
– Product is associated with group A and B
– User CANNOT see product in the listings, search, or can access the product directly.
Scenario 3
– User is in group B
– Product is associated with group A
– User CANNOT see product in the listings, search, or can access the product directly.
Scenario 4
– User is in group B
– Product is associated no groups
– User CAN see product in the listings, search, and access the product directly.
Scenario 5
– User is in group B
– Product is associated group B
– User CANNOT see product in the listings, search, or access the product directly.
Hi Brad,
Many thanks for providing the details, just to let you know we’re looking into it to see what we can suggest. Ideally a logical approach might help you without the need to use customized inverse logic on groups, but we’ll need to pick our brains to see if that’s viable.
We’ll follow up as soon as we have given it a little more thought …
Cheers
Thank you.
For some added context, I have more than just Group A that is in the positive bucket.
In reality I have Group A, C, D, E that are all positive. And some of them are granting access at a category level.
Then there is Group B that I need to use to ensure that users in that group cannot see or access any products associated with Group B.
Just wanted to check back in on this to see what direction you can provide.
Hi Brad,
Thanks for bearing with us, it took a bit to look into it and this is what I would suggest based on my understanding of what you require:
Our groups-wc-not-purchasable repository contains a plugin that does what you need. If you check the description, you can use it to make products not purchasable and not visible for members of certain groups.
You will need to implement the
groups_wc_not_purchasable_category_to_group
as shown there, and use a category for those products that should not be purchasable/visible for members of the specific group.Please give that a try and let us know if you have any questions.
Cheers!
I have installed and implemented it, and it looks like it will do the trick.
I’ve successfully hidden the ability to purchase the products I want, but I also want the items to be hidden from the library completely for that group.
I tried adding this code (from the instructions) to take care of that, but it isn’t working. The items are still visible in the library. Is there something else I need to do?
add_filter( ‘groups_wc_not_purchasable_filter_visibility’, ‘my_groups_wc_not_purchasable_filter_visibility’, 10, 3 );
function my_groups_wc_not_purchasable_filter_visibility( $filter_visibility, $visible, $product_id ) {
return false;
}
Hi Brad,
Welcome to our support forum and many thanks for using our access restriction software on your site.
As you can imagine, the first approach would be to revert the whole functionality of the plugin and do the opposite of what applies at the moment.
However, I think that it would be better if you could provide some further details just in case there is an easier way to do it.
For example, do you wish that feature to apply for all groups, new and existing, or for a specific group only.
As for the rest of the users and visitors, should they have access to that content or not.
Last but not least, if you wish the restriction to apply only to the post content, instead of the whole post, then you can restrict that easily with a custom template. The post(s) will still be found in search results but the content itself will be restricted.
Please let me know what is the approach you’re looking for to use on your site.
Kind regards,
George