WordPress filter hook · part of WordPress core

avatar_defaults

A WordPress core filter that 8 plugins also fire themselves, running on 297K+ sites between them.

“This filter is documented in wp-admin/options-discussion.php”

How to use avatar_defaults

It's a filter: your callback receives the value, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'avatar_defaults', function( $avatar_defaults ) {
	// Change $avatar_defaults here.
	return $avatar_defaults;
}, 10, 1 );

Argument names come from ProfilePress's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

This hook is fired by WordPress core too. Official reference on developer.wordpress.org →

8 plugins that fire avatar_defaults

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. ProfilePress icon ProfilePress100,000+ installs apply_filters( 'avatar_defaults', $avatar_defaults ) deprecated/wp-user-avatar/includes/class-wp-user-avatar-admin.php:210
  2. One User Avatar icon One User Avatar100,000+ installs apply_filters( 'avatar_defaults', $avatar_defaults ) includes/class-wp-user-avatar-admin.php:371
  3. BuddyPress icon BuddyPress90,000+ installs apply_filters( 'avatar_defaults', array_fill_keys( array( 'mystery', 'blank', 'gravatar_default', 'identicon', 'wavatar', 'monsterid', 'retro', ), '' ) ) bp-core/bp-core-avatars.php:117
  4. Leira Letter Avatar icon Leira Letter Avatar6,000+ installs apply_filters( 'avatar_defaults', $avatar_defaults ) includes/class-leira-letter-avatar-sanitizer.php:80
  5. User Avatar icon User Avatar700+ installs apply_filters( 'avatar_defaults', $avatar_defaults ) includes/class-wp-user-avatar-admin.php:242
  6. Eazy Plugin Manager icon Eazy Plugin Manager80+ installs apply_filters( 'avatar_defaults', $avatar_defaults ) libs/class.rest_api.php:1489
  7. WP Core Settings Reduction Project icon WP Core Settings Reduction ProjectFewer than 10 installs apply_filters( 'avatar_defaults', $avatar_defaults ) replacements/options-discussion.php:244
  8. RDDevLabs Smart Dashboard icon RDDevLabs Smart DashboardFewer than 10 installs apply_filters( 'avatar_defaults', array( 'mystery' => '', 'blank' => '', 'gravatar_default' => '', 'identicon' => '', 'wavatar' => '', 'monsterid' => '', 'retro' => '' ) ) includes/class-rddevlabs-smart-dashboard-core-settings.php:144

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.