An “is” could be a good solutions…
in my function.php i have implemented this:
function add_buddypress_avatar( $user_id, $provider, $hybridauth_user_profile ) {
$user = get_userdata( $user_id );
$uploads = wp_upload_dir();
define( 'AC_AVATAR_BASE_PATH', $uploads['basedir'] . '/avatars/' );
define( 'AC_PROFILE_PHOTO_BASE_PATH', $uploads['basedir'] . '/social/' );
$avatarUrl = get_user_meta( $user_id, 'wsl_user_image', true );
// $ch = curl_init( $avatarUrl . '&redirect=false' );
$ch = curl_init( $avatarUrl );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 10 ); // Mean 10 seconds
$content = curl_exec( $ch );
$data = json_decode( $content, true );
curl_close( $ch );
if ( !file_exists( AC_AVATAR_BASE_PATH . $user->ID ) ) {
mkdir( AC_AVATAR_BASE_PATH . $user->ID, 0777, true );
copy( $data["data"]["url"], AC_AVATAR_BASE_PATH . $user->ID . '/avatar-' . $user->user_nicename . '-bpfull.jpg' );
copy( $data["data"]["url"], AC_AVATAR_BASE_PATH . $user->ID . '/avatar-' . $user->user_nicename . '-bpthumb.jpg' );
}
}
add_action( 'wsl_hook_process_login_before_redirect', 'add_buddypress_avatar', 10, 3 );