pre_get_avatar_data
Filter HookDescription
Filters whether to retrieve the avatar URL early. Passing a non-null value in the 'url' member of the return array will effectively short circuit get_avatar_data(), passing the value through the {@see 'get_avatar_data'} filter and returning early.Hook Information
File Location |
wp-includes/link-template.php
View on GitHub
|
Hook Type | Filter |
Line Number | 4477 |
Hook Parameters
Type | Name | Description |
---|---|---|
array
|
$args
|
Arguments passed to get_avatar_data(), after processing. |
mixed
|
$id_or_email
|
The avatar to retrieve. Accepts a user ID, Gravatar SHA-256 or MD5 hash, user email, WP_User object, WP_Post object, or WP_Comment object. |
Usage Examples
Basic Usage
<?php
// Hook into pre_get_avatar_data
add_filter('pre_get_avatar_data', 'my_custom_filter', 10, 2);
function my_custom_filter($args, $id_or_email) {
// Your custom filtering logic here
return $args;
}
Source Code Context
wp-includes/link-template.php:4477
- How this hook is used in WordPress core
<?php
4472 *
4473 * @param array $args Arguments passed to get_avatar_data(), after processing.
4474 * @param mixed $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar SHA-256 or MD5 hash,
4475 * user email, WP_User object, WP_Post object, or WP_Comment object.
4476 */
4477 $args = apply_filters( 'pre_get_avatar_data', $args, $id_or_email );
4478
4479 if ( isset( $args['url'] ) ) {
4480 /** This filter is documented in wp-includes/link-template.php */
4481 return apply_filters( 'get_avatar_data', $args, $id_or_email );
4482 }
PHP Documentation
<?php
/**
* Filters whether to retrieve the avatar URL early.
*
* Passing a non-null value in the 'url' member of the return array will
* effectively short circuit get_avatar_data(), passing the value through
* the {@see 'get_avatar_data'} filter and returning early.
*
* @since 4.2.0
*
* @param array $args Arguments passed to get_avatar_data(), after processing.
* @param mixed $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar SHA-256 or MD5 hash,
* user email, WP_User object, WP_Post object, or WP_Comment object.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/link-template.php
Related Hooks
Related hooks will be displayed here in future updates.