Skip Navigation

[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.

You can find the proposed solution in this case with the following reply:
https://toolset.com/forums/topic/setting-up-a-filter-for-a-custom-user-role-field/#post-2258051

Relevant Documentation:
- https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

This support ticket is created 2 years, 12 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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 19 replies, has 2 voices.

Last updated by martham 2 years, 11 months ago.

Assisted by: Minesh.

Author
Posts
#2258135

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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.

#2258393

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.

#2258747

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.

#2258883

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Great - you are welcome to mark resolve this ticket.

#2259335

My issue is resolved now. Thank you!