I am attempting to display a woocommerce product category page based on the current user role. I have created a custom function get_user_role()
to get the user role and added the shortcode [user_role] to fetch this. If I use the shortcode on a page it successfully returns "administrator" so I can confirm this custom shortcode is working.
I am now having trouble using this shortcode as the category slug.
So what I am trying to achieve is essentially the following:
[product_category category='[user_role]']
How can I make it work?
May be you are doing it in the wrong way, or may be you need to create an additional shortcode.
So the code should be something like:
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
SIMPLE USAGE (Example):
This code is tested and works. You will get something like this:
Similar answer: WordCommerce shortcode products list