I use Types to create a repeatable field to PRODUCTS. My purpose is that different products are visible only to specific users.
For example:
I have 2 users (Username: hwk1, hwk2) and 3 products.
In the repeater field of the products, I put the value as below in order to match with username.
Product 1: hwk1
Product 2: hwk2
Product 3: hwk1, hwk2
I hope that after hwk1 is logged in, he can only see the product 1 + 3, and hwk2 only see product 2 + 3.
Is it possible? Could show me how to do it?
Thanks.
Is this just a simplified example and in reality you would have many more products and many more users?
Because if it is fairly simple like this, you can use Access and create a post group for posts that would only be seen by hwk1, a post group for posts that would only be seen by hwk2, and a post group for posts that would be seen by both, and then set permissions for individual users for each group.
But if you had more products/users it would start to get too complex.
In which case you would need a different solution, but let me know first...
Yes, it is just a simple example to express what I want. I do have more users/products now and may have many more in the future.
Due to not so many users/products at this stage, I will try to use the way you provide.
In case there are many in the future, do you have any better suggestions?
Your instruction above works fine, but I have another question:
Are the Access permissions only for the single page and not for archive page?
I hope that when hwk1 is logged in, he can see the single and archive pages that only belong to him.
The archive pages with no permission will not be visible to him.
OK, if your use-case will become more complex then we should plan for that from the beginning.
So, rather than using Access you should use wpv-conditional shortcodes to restrict visibility (which you can use both in Views or Archives). You probably don't need to worry about using them on the templates for single posts, unless you are worried users might guess the URLs, in which case you could also wrap the content of the entire template in such a conditional.
As for how the conditional should work, in this scenario it makes more sense to me to use a taxonomy to specify who should get access. So you would make a taxonomy where you add terms that match the name/slug of the users.
Then edit posts and check the users that should be able to see the post.
Then in your Views, archives, or even individual templates, wrap the content in a conditional shortcode, like so:
Now, I encounter a problem. I am using the theme Astra pro+Elementor pro.
After installing Toolset Views, following messages appear at Elementor page:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, cannot access private method Astra_Addon_Background_Updater::needs_db_update() in.................
After I disable Astra pro and change to the default theme Twenty Twenty , it is back to normal and the error messages disappear.
Do Astra pro conflict with Toolset?
What should I do?
Thanks.