Created
July 21, 2017 10:33
-
-
Save anonymous/551f22507b7edf2be1b70d4c5a9f86c9 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
add_filter('get_avatar_url', 'wpse_avatar_or_gravatar', 10, 3); | |
function wpse_avatar_or_gravatar($url, $email, $args) { | |
// Manually edit the /wp-admin/includes/class-wp-users-list-table.php (439) and /wp-includes/admin-bar.php to show avatar using email | |
$path = sprintf('/home/asdasd/public_html/wp-content/images/users/%s.jpg', | |
md5(strtolower(trim($email . "scripto"))) | |
); | |
$url = sprintf('%s/images/users/%s.jpg', | |
"//www.asd.com/wp-content", | |
md5(strtolower(trim($email . "scripto"))) | |
); | |
if (file_exists($path)) { | |
// image exists, return url | |
$url = sprintf('//www.asd.com/wp-content/images/users/%s.jpg', | |
md5(strtolower(trim($email . "scripto"))) | |
); | |
} | |
else { | |
// image does not exist, return default avatar | |
$url = "https://0.gravatar.com/avatar/" . md5( strtolower( trim( $email ) ) ) . "?s=64&d=identicon&f=y&r=g"; | |
} | |
return $url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment