This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Ajax Search Pro and ACF

#40668
timgrahltimgrahl
Participant

Ok, I found these two pages:

https://documentation.ajaxsearchpro.com/advanced-options/excluding-and-including-results/exclude-or-include-by-custom-field-values

https://knowledgebase.ajaxsearchpro.com/hooks/filters/query-and-output/asp_query_args#search_type-search-content-types

And added this to my functions.php file:

add_filter('asp_query_args', 'asp_add_my_meta_filter', 10, 1);
function asp_add_my_meta_filter( $args ) {

	$args['search_type'] = array('users');
	$args['post_meta_filter'] = array(
		array(
			'key'     => 'public_profile',         // meta key
			'value'   => 'yes', // int|float|string|array|timestamp|datetime
			'operator' => 'LIKE',
			'allow_missing' => false   // allow match if this custom field is unset
		));
  return $args;
}

But it’s still returning users with public_profile set to “no”.

Any ideas?