From 3257460799ae448ee4954066f61db57ca4306c84 Mon Sep 17 00:00:00 2001 From: Ale46 Date: Sun, 24 Jan 2016 20:05:26 +0100 Subject: [PATCH] Added option to get avatar without Buddypress for Wordpress 4.2+ --- controllers/User.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/controllers/User.php b/controllers/User.php index 5a1c22f..9731b09 100644 --- a/controllers/User.php +++ b/controllers/User.php @@ -167,9 +167,16 @@ public function get_avatar(){ return array('avatar'=>$avatar); } else { - - $json_api->error("You must install and activate BuddyPress plugin to use this method."); - + global $wp_version; + + if ($wp_version >= 4.2){ + $size = 50; + if ($json_api->query->type == "full") + $size = 150; + $args = get_avatar_data( $json_api->query->user_id, array('size'=> $size )); + return array('avatar'=> $args['url'] ); + } + $json_api->error("You must install and activate BuddyPress plugin to use this method or upgrade to Wordpress 4.2+"); } }