I have many, many WordPress authors. For each, I have used the custom wp_usermeta profile field "photo_url" to store URLs for different remotely-hosted avatar images.

I am currently displaying these image avatars on author.php by echoing the strings through the img HTML tag. But I'd like to more closely integrate them with WordPress, by making them available through get_avatar, as though they were standard avatars.

I have looked at several threads here, including on disabling Gravatar. That's good, but how do I then make sure the URLs can be accessed through all standard WordPress avatar hooks in places I want to - ie. on author profiles, posts and loops?

(I also want to default to get_template_directory_uri() . '/images/avatar_default.png' whenever the "photo_url" has no value.


1 Answer 1


Unless I have misunderstood your question to accomplish a custom gravatar to use in your theme add the code below to your functions.php or into a custom plugin.

From there customize the title and the image you want to use. See screenshot below for the finished outcome.

add_filter( 'avatar_defaults', 'dev_designs_gravatar' );
 * Display a custom Gravatar
 * @param       $avatar
 * @return      mixed
 * @author      Joe Dooley - [email protected]
function dev_designs_gravatar( $avatar ) {
    $custom_avatar            = get_stylesheet_directory_uri() . '/images/avatar_default.png';
    $avatar[ $custom_avatar ] = "Custom Gravatar";

    return $avatar;

See Custom Avatar in top right of the admin bar. Select new Custom Gravatar option to set default gravatar for theme.

  • Thanks, Joe, but I'm not sure what this is supposed to do. If I'm reading you correctly, this would set a default blank anonymous avatar using the URL I gave (which, incidentally, is the same as "Mystery Person" - I didn't even know this setting existed, so seems futile for me to replicate it). But a default avatar for avatar-less people is only the minor part - what I really want to do is change the whole avatar system so that the URLs stored in field "photo_url" in wp_usermeta (different for every user and all remotely hosted) become those people's avatars, accessible through get_avatar. Commented Mar 2, 2016 at 10:17
  • What the function above will do is create another default avatar option. If you look at the last avatar, called Custom Gravatar... This is what the code I provided has done. Essentially you can create your own default Gravatar and assign that to all users. If I'm understanding you correctly. You want each user to have the ability to upload their own custom Gravatar from their User Profile -> Edit screen. Am I understanding you correctly? If so... It's possible and that can be accomplished quite easily with CMB2 or ACF/ACF Pro. Of course you could create your own custom meta boxes too.
    – Joe Dooley
    Commented Mar 2, 2016 at 11:29
  • No, I'm afraid that's not it either. My user database (table wp_usermeta) already contains the value for everyone's avatar, stored in "photo_url" - it's a URL to a remotely-hosted image. This is the image that I'd like to be the user's avatar (different for every user). No uploads required at this stage, and a default fallback avatar is just one useful part, because a minority of my users has no value in photo_url. I'm not sure why creating custom meta boxes would help (although that's something I want to do to make all my fields editable). CMB2 and ACF are things I should explore. Commented Mar 2, 2016 at 11:50
  • I would have to see your codebase to provide you a more precise answer to this one. Just in case you don't have too many users and want to provide them with the ability to change their avatars easily in the future you might want to take a look at this article. Whenever I have implemented custom user avatars I have used a similar solution as in this article. This is what I meant by custom meta boxes in the user profile area. thestizmedia.com/acf-pro-simple-local-avatars Best of luck!
    – Joe Dooley
    Commented Mar 2, 2016 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.