Last update (1.0.8) broke BuddyPress avatars
-
Hello,
In the last update the Facebook avatar is replacing BuddyPress avatars no matter what you do.
The “Facebook Avatars?” checkbox is not honored at all weather it’s enabled or disabled, it always shows the Facebook avatar.
I also can’t replace the Facebook avatar with anything else via BuddyPress’ “Change Profile Photo” feature. It remains no matter what you do.
The desired behavior for me would be to not use Facebook avatar if the checkbox is not checked. If it is, then use the Facebook avatar until someone uploads a new avatar via “Change Profile Photo.”
In the last version (1.0.7.2) I also had it download the Facebook avatar (rather than just linking to Facebook) using some custom code. Worked alright, but there was a bug in the thumb version not updating which I hadn’t worked out yet. Code provided below in case it is useful. Inspired by the BP Social Connect plugin.
/* get facebook avatar on login */ function grab_avatar($link,$type,$user_id){ $base_dir=wp_upload_dir(); $dir = $base_dir['basedir'].'/avatars/'.$user_id; is_dir($dir) || @mkdir($dir) || die(__("Can't Create folder","bp_social_connect")); if (!file_exists($dir)) { mkdir($dir, 0777, true); } if(is_writable($dir)){ //Get the file $content = file_get_contents($link); if($type == 'thumb'){ $fp = fopen($dir .'/'.$user_id.'-bpthumb.jpg', 'w'); }else if($type=='full'){ $fp = fopen($dir .'/'.$user_id.'-bpfull.jpg', 'w'); } fwrite($fp, $content); fclose($fp); } } function bws_facebook_login($user, $user_id) { $fb_id = $user['fb_user_id']; $thumb = 'https://graph.facebook.com/'.$fb_id.'/picture?width='.BP_AVATAR_THUMB_WIDTH.'&height='.BP_AVATAR_THUMB_HEIGHT; $full = 'https://graph.facebook.com/'.$fb_id.'/picture?width='.BP_AVATAR_FULL_WIDTH.'&height='.BP_AVATAR_FULL_HEIGHT; grab_avatar($thumb,'thumb',$user_id); grab_avatar($full,'full',$user_id); } add_action( 'fbl/after_login', 'bws_facebook_login', 10, 2);
- The topic ‘Last update (1.0.8) broke BuddyPress avatars’ is closed to new replies.