Skip Navigation

[Resolved] User view with "OR" in the query filter

This support ticket is created 3 years, 1 month 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Karachi (GMT+05:00)

This topic contains 4 replies, has 2 voices.

Last updated by Waqar 3 years, 1 month ago.

Assisted by: Waqar.

Author
Posts
#2232767

Hello how are you?

I created a users view, with a search field, and I would like this search to make a query in several custom fields at the same time (ex: name, city, neighborhood) using LIKE and all fields are STRING.

I configured the query filters, all right, however, I can't change from AND to OR, so that the search works correctly.

can you help me?

I'm waiting

thanks

#2232851

Hi,

Thank you for contacting us and I'd be happy to assist.

To suggest the best way to achieve this, I'll need to see how this view is set up in the admin area.

Can you please share temporary admin login details, along with the link to the page with this view?

Note: Your next reply will be private and it is recommended to make a complete backup copy, before sharing the access details.

regards,
Waqar

#2234021

Thank you for sharing these details.

To change the relations operator between the multiple custom fields filter to "OR", you can use the "wpv_filter_query" filter:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

For example:


add_filter( 'wpv_filter_query', 'wpv_filter_query_func', 1000 , 3 );
function wpv_filter_query_func( $query_args, $view_settings ) {
	// process if specific view
	if ( ( isset($view_settings['view_id']) && $view_settings['view_id'] == 1234) ) {
		if( !empty($query_args['meta_query']) ) {
			$query_args['meta_query']['relation'] = 'OR';
		}
	}
	return $query_args;
}

Note: Please replace '1234' with the actual ID of your target view.

The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.

#2234181

ok, I got it...

but what happens? does it have to be through code? don't have this native option in the visual filter selector?

thanks

#2234217

Thanks for writing back.

We have an internal ticket to bring back the visual operator selection, for cases, where multiple custom field filters are involved.

I'm afraid, it won't be possible to share any time estimate, so for now, you can override it only using the code.