Created
March 28, 2016 19:52
-
-
Save norcross/0a5b72c0ba6c8b16d32c to your computer and use it in GitHub Desktop.
Remove user avatars from the admin user table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'pre_get_avatar', 'rkv_remove_avatar_from_list', 10, 3 ); | |
/** | |
* Remove the avatars from just the admin user list table. | |
* | |
* @param string $avatar HTML for the user's avatar. Default null. | |
* @param mixed $id_or_email The Gravatar 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 An empty string. | |
*/ | |
function rkv_remove_avatar_from_list( $avatar, $id_or_email, $args ) { | |
// Do our normal thing on non-admin or our screen function is missing. | |
if ( ! is_admin() || ! function_exists( 'get_current_screen' ) ) { | |
return $avatar; | |
} | |
// Get my current screen. | |
$screen = get_current_screen(); | |
// Bail without the object. | |
if ( empty( $screen ) || ! is_object( $screen ) || empty( $screen->base ) || 'users' !== $screen->base ) { | |
return $avatar; | |
} | |
// Return an empty string. | |
return ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment