-
-
Save billerickson/30fa3bda007930f4955f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function be_gravatar_filter($avatar, $id_or_email, $size, $default, $alt) { | |
// If provided an email and it doesn’t exist as WP user, return avatar since there can’t be a custom avatar | |
$email = is_object( $id_or_email ) ? $id_or_email->comment_author_email : $id_or_email; | |
if( is_email( $email ) && ! email_exists( $email ) ) | |
return $avatar; | |
$avatar_field = ‘ihc_avatar’; //<$avatar_field); | |
$custom_avatar = get_the_author_meta($avatar_field); //GET CUSTOM AVATAR FOR POST-AUTHOR | |
$avatarurl = wp_get_attachment_url($custom_avatar); | |
if ($email_avatar){ //IF CUSTOM AVATAR FOR THIS EMAIL IS FOUND, RETURN. EX. FOR COMMENTS OR BBPRESS FORUM | |
$return = ”; | |
} | |
elseif ($custom_avatar) { //ELSE IF RETURN CUSTOM AVATAR FOR THE POST-AUTHOR | |
$return = ”; | |
} | |
elseif ($avatar) { | |
$return = $avatar; | |
}else { | |
$return = ”; | |
} | |
return $return; | |
} | |
add_filter(‘get_avatar’, ‘be_gravatar_filter’, 10, 5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment