Skip Navigation

[Resolved] Text Search Filter not Respecting Query Args in wpv_filter_query

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 1 reply, has 2 voices.

Last updated by Minesh 1 year, 3 months ago.

Assisted by: Minesh.

Author
Posts
#2628377

Tell us what you are trying to do?
I've set up some taxonomies inside the view filters area. When I use the text search filter (with AJAX) the results respect the taxonomies that have been selected by the users. However, I also have the following in a wpv_filter_query filter:

add_filter( 'wpv_filter_query', 'prefix_no_show_only_current_author', 101, 3 );
function prefix_no_show_only_current_author( $query_args, $views_settings, $view_id ) {
$query_args['author__not_in'] = [222, 234, 432];
return $query_args;
}

This wpv_filter_query filter works fine on load and when changing the taxonomies but if I search with the text box it does not keep those authors filtered out.

How can I get the search filter to keep/respect the wpv_filter_query on search?

Is there any documentation that you are following?
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

Is there a similar example that we can see?
No

What is the link to your site?
This area is behind a paywall.

#2628591

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Normally it should work. But the thing is that when you have text search, text search support AJAX only when there is a submit button added to the form. Do you have submit button added to your search form? If no, can you try to add a submit button and check?

What if you try to change the priority of your "wpv_filter_query" hook to 10 instead of 101.

For example:

add_filter( 'wpv_filter_query', 'prefix_no_show_only_current_author', 10, 3 );
function prefix_no_show_only_current_author( $query_args, $views_settings, $view_id ) {
if( $view_id== 99999 ) { 
         $query_args['author__not_in'] = array(222, 234, 432);
}
return $query_args;
}

Where:
- Replace the 99999 with your original view ID.

If that does not help, do you have any plugin install that may interfere and hijack the query.

Could you please try to resolve your issue by deactivating all third-party plugins as well as the default theme to check for any possible conflicts with any of the plugins or themes?
- Do you see any difference? If no:

I will require problem URL and you can tell me if I need to use any specific keyword for search and send me admin access details and let me see whats going wrong with your setup.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.