Skip Navigation

[Resolved] Hiding content by category and role

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to restrict access to certain content based on a taxonomy and user role

Solution: Instead of a taxonomy, consider a post group. Then you can use role and post group restrictions to manage access for users.

Relevant Documentation: https://toolset.com/documentation/user-guides/setting-access-control/

This support ticket is created 7 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 5 replies, has 2 voices.

Last updated by stewartE 7 years, 4 months ago.

Assisted by: Christian Cox.

Author
Posts
#542069

Hi is it possible to use Access to hide content based on category and role.

For example I have two roles on my website which is a WooCommerce site "Customer" and "Personal"

Customer which is a default role created by WooCommerce should be able to see ALL content

Personal which is a custom role created using cred should ONLY be allowed to see Products under the category personal.

Thanks

#542172

Access can't help you restrict users by post taxonomy...but there might be another way. Instead of a taxonomy that classifies these products you could use a Post Group. When Access manages Products, you can assign each Product into a Post Group. Assign all other hidden products into a different Post Group, and restrict access to specific Post Groups for your custom role. Would that work for your needs?

#542457

Hi I don't think so.

We have over 4000 products so that would mean adding 4000 products into the group which isnt really manageable.

#542548

Just a thought would this post group show up in the database somehow?

So we could assign products to the post group through the database rather than manually going in and adding 4000 products individually one-by-one to the group?

#542619

Yes, you can assign a post group to a post by adding a row to the postmeta table. Make a backup of your database before running any SQL queries.

Manually assign one of your post groups to some product from your wp-admin area. Note the product ID. Now in the wp_postmeta table, find the key _wpcf_access_group associated with this product ID. If you sort the list in reverse order by meta key, it should be very near the top of the list. Copy the meta_value of this item. It will look something like wpcf-custom-group-a40577ebeaa689b791438e4506608a02 but with a different hash.

Finally insert a new row for each post you want to add to this post group. The meta ID will be automatically incremented, the post ID will be the ID of the post, the meta key will be _wpcf_access_group, and the value will be something like wpcf-custom-group-a40577ebeaa689b791438e4506608a02.

#544186

Great thank you