Filter hook 'get_avatar'

in WP Core File wp-includes/pluggable.php at line 3248

View Source

get_avatar

Filter Hook
Description
Filters the HTML for a user's avatar.

Hook Information

File Location wp-includes/pluggable.php View on GitHub
Hook Type Filter
Line Number 3248

Hook Parameters

Type Name Description
string $avatar HTML for the user's avatar.
mixed $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash, user email, WP_User object, WP_Post object, or WP_Comment object.
int $size Height and width of the avatar in pixels.
string $default_value URL for the default image or a default type. Accepts: - '404' (return a 404 instead of a default image) - 'retro' (a 8-bit arcade-style pixelated face) - 'robohash' (a robot) - 'monsterid' (a monster) - 'wavatar' (a cartoon face) - 'identicon' (the "quilt", a geometric pattern) - 'mystery', 'mm', or 'mysteryman' (The Oyster Man) - 'blank' (transparent GIF) - 'gravatar_default' (the Gravatar logo)
string $alt Alternative text to use in the avatar image tag.
array $args Arguments passed to get_avatar_data(), after processing.

Usage Examples

Basic Usage
<?php
// Hook into get_avatar
add_filter('get_avatar', 'my_custom_filter', 10, 6);

function my_custom_filter($avatar, $id_or_email, $size, $default_value, $alt, $args) {
    // Your custom filtering logic here
    return $avatar;
}

Source Code Context

wp-includes/pluggable.php:3248 - How this hook is used in WordPress core
<?php
3243  		 *                              - 'blank' (transparent GIF)
3244  		 *                              - 'gravatar_default' (the Gravatar logo)
3245  		 * @param string $alt           Alternative text to use in the avatar image tag.
3246  		 * @param array  $args          Arguments passed to get_avatar_data(), after processing.
3247  		 */
3248  		return apply_filters( 'get_avatar', $avatar, $id_or_email, $args['size'], $args['default'], $args['alt'], $args );
3249  	}
3250  endif;
3251  
3252  if ( ! function_exists( 'wp_text_diff' ) ) :
3253  	/**

PHP Documentation

<?php
/**
		 * Filters the HTML for a user's avatar.
		 *
		 * @since 2.5.0
		 * @since 4.2.0 Added the `$args` parameter.
		 *
		 * @param string $avatar        HTML for the user's avatar.
		 * @param mixed  $id_or_email   The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
		 *                              user email, WP_User object, WP_Post object, or WP_Comment object.
		 * @param int    $size          Height and width of the avatar in pixels.
		 * @param string $default_value URL for the default image or a default type. Accepts:
		 *                              - '404' (return a 404 instead of a default image)
		 *                              - 'retro' (a 8-bit arcade-style pixelated face)
		 *                              - 'robohash' (a robot)
		 *                              - 'monsterid' (a monster)
		 *                              - 'wavatar' (a cartoon face)
		 *                              - 'identicon' (the "quilt", a geometric pattern)
		 *                              - 'mystery', 'mm', or 'mysteryman' (The Oyster Man)
		 *                              - 'blank' (transparent GIF)
		 *                              - 'gravatar_default' (the Gravatar logo)
		 * @param string $alt           Alternative text to use in the avatar image tag.
		 * @param array  $args          Arguments passed to get_avatar_data(), after processing.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 6
  • File: wp-includes/pluggable.php
Related Hooks

Related hooks will be displayed here in future updates.