[Resolved] Setting up a filter for a custom user role field
This thread is resolved. Here is a description of the problem and solution.
Problem:
Setting up a filter for a custom user role field - how to filer and display WooCommerce orders based on different role
Solution:
You can pass the role name as view's shortcode argument and then use the 'wpv_filter_query' filter to filter the orders based on the passed role.
Then I don't even have to use a different View for each one, right?
==>
Yes - thats right.
I can just use the same one and it will only display the role I choose for that page on the page, correct?
===>
Yes, thats correct. Having said that you need to mention what role you want to display using view's shortcode. For instance:
<h1> Order for Customer Role </h1>
[wpv-view name="member-names-membership-levels-admin" role="customer"]
Great to know that solution I shared help you to resolve your issue.
OK, I'll let you know when I get all the role pages set up and views and code set up on those pages. Once that's done and I see no remaining issues we'll be able to mark this one as resolved.
I now have everything set up to function the way we wanted it. Your workaround solution is now set up to emulate a filter. I set up all the individual role pages into a new menu on the site. Then I found a plugin called Menu In Posts that allows for the placement of a shortcode to display a menu in the page either as a list of links or as a dropdown. I used the dropdown setting.
Here is the final result of all this effort in case you're curious to see how I applied everything.
hidden link
Thanks hugely again for all the help in implementing this work-around solution that barely seems like a work-around once it's all set up. The only way it's a workaround is the dropdown menu leads to separate pages for each result rather than cnanging the results on the one page. But this is fine.
Note that I placed the shortcode in the filter area for the view above the date range filter so I only had to add this once since the same view is being used on all individual role pages. Overall, excellent workaround that achieved the desired results.
I'll mark this thread as resolved. The only way we'll have to revisit it is if I see issues when we start getting orders under each of the different roles and something isn't right. I think it will be OK though. But it is possible that something will need further tweaking.