Hello Ernest,
Excuseme for writing again for the same topic I opened before; I can’t find a solution for it.
I’m still trying to display the wp_get_attachment_image from the users in my theme default search results page in order to display it next to their usernames as avatar.
The code I have can display correctly $args and $avatar in the header of the page, AND $args in the users list search results, but not $avatar in the users list search results.
I think it coul be because it can’t get correctly $user->ID in the user list search results, so I would like to ask you the way Ajax Search Pro plugin get users in the search results page in order to modify my code.
This is what I have now:
function my_user_avatar_filter( $avatar, $id_or_email, $args) {
$id_or_email = get_userdata($id_or_email);
$attachment_id = get_user_meta( $id_or_email->ID, ‘foto’, true );
if (get_user_meta( $id_or_email->ID, ‘foto’, true )){
//$avatar_url = wp_get_attachment_url( $attachment_id, $size );
//$avatar = “
“;
$size= array(’80’,’80’);
$avatar = wp_get_attachment_image($attachment_id, $size);
echo $avatar;
} else {
$args=”
“;
echo $args;
}
}
add_filter( ‘get_avatar’, ‘my_user_avatar_filter’, 10, 3 );
Thank you,