WordPress Snippets at WPcustoms

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: http://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 ' );