Forums

[Plugin: User Photo] Show thumb only if there's no gravatar (1 post)

  1. adastra
    Member
    Posted 2 years ago #

    I tried to use the snippet in the wordpress wiki to first check if there's a gravatar, and only if there isn't one I want user photo to display the user thumbail. But it's not working, because it's not showing the gravatar (only the fallback avatar like monsterid). I DO NOT want to override all the gravatars with the user photo, they should only be displayed if there's no gravatar.

    Can anyone help with this?!

    function validate_gravatar($email) {
    	$hash = md5($email);
    	$uri = 'http://www.gravatar.com/avatar/' . $hash . '?d=404';
    	$headers = @get_headers($uri);
    	if (!preg_match("|200|", $headers[0])) {
    		$has_valid_avatar = get_avatar($email, '80');
    	} else {
    		$has_valid_avatar = userphoto_the_author_thumbnail($author);
    	}
    	return $has_valid_avatar;
    }

    Trying to call the function:
    echo validate_gravatar(get_the_author_meta('user_email'));

Topic Closed

This topic has been closed to new replies.

About this Topic