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

Reply To: Including user roles when do user search

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Including user roles when do user search Reply To: Including user roles when do user search

#30602
Ernest MarcinkoErnest Marcinko
Keymaster

Hi Zarko,

Well, there is no option for that, but you can try using the asp_query_args filter to maybe use a programmatical solution to filter by user meta.

Try something like this:

add_filter("asp_query_args", "asp_query_args_change", 10, 2);
function asp_query_args_change($args, $search_id) {
	// Roles list
	$roles = array('role1', 'role2');

	global $wpdb;
	$args['user_meta_filter'][] = array(
		'key'     => $wpdb->base_prefix."capabilities',
		'value'   => roles,
		'operator' => 'IN',
		'allow_missing' => false
	);

  return $args;
}

Add the roles to the $roles array variable. I could not test this code, so please be careful, read the safe coding guide.