apply_filters( ‘avatar_defaults’, string[] $avatar_defaults )

Filters the default avatars.

Description

Avatars are stored in key/value pairs, where the key is option value, and the name is the displayed avatar name.

Parameters

$avatar_defaultsstring[]
Associative array of default avatars.

Source

$avatar_defaults = apply_filters( 'avatar_defaults', $avatar_defaults );

Changelog

VersionDescription
2.6.0Introduced.

User Contributed Notes

  1. Skip to note 2 content

    Put the image address on the key and a title for it on the value.

    function wpdocs_new_gravatar( $avatar_defaults ) {
    	$new_default_avatar = 'https://mysite.com/wp-content/uploads/user.jpg';
    	$avatar_defaults[ $new_default_avatar ] = 'Default Gravatar I chose';
    
    	return $avatar_defaults;
    }
    add_filter( 'avatar_defaults', 'wpdocs_new_gravatar' );

    After that, you must go to Settings >> Discussion > Default Avatar and you’ll see the new image in the bottom of options for gravatar. Select it and save changes.

    You can see the new avatars in action going to Edit Users admin sreen.

You must log in before being able to contribute a note or feedback.