pre_get_avatar WordPress Filter Hook

The pre_get_avatar hook is a great way to get the avatar for a user before it is displayed on the front end of your site. This can be useful if you want to cache the avatar or if you want to change the way the avatar is displayed.

apply_filters( 'pre_get_avatar', string|null $avatar, mixed $id_or_email, array $args ) #

Allows the HTML for a user’s avatar to be returned early.


Description

Returning a non-null value will effectively short-circuit get_avatar(), passing the value through the ‘get_avatar’ filter and returning early.


Top ↑

Parameters

$avatar

(string|null)HTML for the user's avatar. Default null.

$id_or_email

(mixed)The avatar to retrieve. Accepts a user_id, Gravatar MD5 hash, user email, WP_User object, WP_Post object, or WP_Comment object.

$args

(array)Arguments passed to get_avatar_url(), after processing.


Top ↑

Source

File: wp-includes/pluggable.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
4.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More