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

Reply To: User results have no profile image

Home Forums Product Support Forums Ajax Search Pro for WordPress Support User results have no profile image Reply To: User results have no profile image

#24774
Ernest MarcinkoErnest Marcinko
Keymaster

Hi,

I think I may have found something. There is a user meta field “peepso_avatar_hash” that seems to be linked with the avatar generation. I have looked at the final user avatar URLs, and it looks like it’s all the same, except this hash and the user ID.
The default WordPress get_avatar() function does not return anything here. The only way to resolve this is via a custom code.

Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!

add_filter('asp_results', 'asp_peepso_avatar_fix', 10, 1);
function asp_peepso_avatar_fix($results) {
	foreach ($results as &$r) {
		if ( $r->content_type == 'user' ) {
			$hash = get_user_meta($r->id, 'peepso_avatar_hash', true);
			if ( !empty($hash) ) {
				$r->image = get_site_url() . '/wp-content/peepso/users/' . $r->id . '/' . $hash . '-avatar-full.jpg';
			}
		}
	}
	return $results;
}

If all goes well, this should resolve the avatar URLs in the live results.