Change default gravatar

WordPress offers a default avatar for registered users who don’t have a profile image. If you want to change that boring default image this function helps you to do so. Easily overwrite the default gravatar url with your image in your theme folder.

/**
 * Snippet Name: Change default gravatar
 * Snippet URL: https://www.wpcustoms.net/snippets/change-default-gravatar/
 */
  function wpc_newgravatar ($avatar_defaults) {
    $myavatar = get_template_directory_uri() . '/images/custom-gravatar.jpg';
    $avatar_defaults[$myavatar] = "Custom Avatar";
    return $avatar_defaults;
}
add_filter( 'avatar_defaults', 'wpc_newgravatar ' ); 

0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x