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

Filters the default avatars.


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


Associative array of default avatars.


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



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 = '';
    	$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.