/* Remove Avatar (Photo Profile) if is not found */
function custom_avatar_url( $url, $id_or_email, $args ) {
$url_args = array(
's' => $args['size'],
'd' => '404',
'f' => $args['force_default'] ? 'y' : false,
'r' => $args['rating'],
);
$custom_url = add_query_arg(
rawurlencode_deep( array_filter( $url_args ) ),
set_url_scheme( $url, $args['scheme'] )
);
$response = wp_remote_get( $custom_url );
if ( 404 === wp_remote_retrieve_response_code( $response ) ) {
return false;
}
return $custom_url;
}
add_filter( 'get_avatar_url', 'custom_avatar_url', 99, 3 );