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

Reply To: Excluding a specific role from the search?

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Excluding a specific role from the search? Reply To: Excluding a specific role from the search?

#30362
Ernest MarcinkoErnest Marcinko
Keymaster

Hi,

Well, probably, but only in post process. I recommend the asp_results hook for that. Maybe this custom code would work:

add_action("asp_results", "asp_exclude_by_role");
function asp_exclude_by_role($results) {
	$exclude_role = 'role_name';

	foreach ( $results as $k => &$r ) {
		if ( isset($r->post_type) && in_array( $exclude_role, ( new WP_User( $r->author ) )->roles ) ) {
			unset($results[$k]);
		}
	}
	
	return $results;
}