pre_get_avatar
Allows the HTML for a user's avatar to be returned early.
Returning a non-null value will effectively short-circuit get_avatar(), passing the value through the get_avatar filter and returning early.
Использование
add_filter( 'pre_get_avatar', 'wp_kama_pre_get_avatar_filter', 10, 3 ); /** * Function for `pre_get_avatar` filter-hook. * * @param string|null $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 array $args Arguments passed to get_avatar_url(), after processing. * * @return string|null */ function wp_kama_pre_get_avatar_filter( $avatar, $id_or_email, $args ){ // filter... return $avatar; }
- $avatar(строка|null)
- HTML for the user's avatar.
По умолчанию: null - $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.
- $args(массив)
- Arguments passed to get_avatar_url(), after processing.
Список изменений
С версии 4.2.0 | Введена. |
Где вызывается хук
pre_get_avatar
wp-includes/pluggable.php 2910
$avatar = apply_filters( 'pre_get_avatar', null, $id_or_email, $args );