Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: WP-FB connect profile.


joshmac
Participant

@parkstreet

Ok, this is what I’ve come up with so far in order to get the user’s facebook profile pic. However, they disappear when you log in. If anyone is willing to add to this to give it the finishing touch it needs or can tell me what to add that would be great.

add_action('wpfb_login', 'bp_jfb_get_avatar');

function bp_jfb_get_avatar($avatar, $id_or_email='') {
global $comment; $id_or_email;

if(is_object($comment)) {
$user_id = $comment->user_id;
}

if (is_object($id_or_email)) {
$user_id = $id_or_email->user_id;
}

if (is_array($id_or_email)) {
if ($id_or_email['object']=='user') {
$user_id = $id_or_email['item_id'];
}
}

if (get_usermeta($user_id, 'facebook_uid')) {
$user_info = get_userdata($user_id);
$jfb_suffix = '';

if ( $id_or_email['width'] ) {
$jfb_size = $id_or_email['width'];
if( $jfb_size < 32 ) {
$jfb_suffix = 'm';
} else if ( $jfb_suffix < 64 ) {
$jfb_suffix = 'n';
} else {
$jfb_suffix = 'b';
}
} else if ( 'full' == $id_or_email['type'] ) {
$jfb_size = BP_AVATAR_FULL_WIDTH;
$jfb_suffix = 'b';
} else if ( 'thumb' == $id_or_email['type'] ) {
$jfb_size = BP_AVATAR_THUMB_WIDTH;
$jfb_suffix = 'n';
}
$avatar = '<fb:profile-pic uid="'.$user_info->facebook_uid.'" facebook-logo="true" size="'.$jfb_size.'" width="'.$jfb_size.'" linked="true" class="avatar"></fb:profile-pic>';
return $avatar;

} else {
return $avatar;
}

}
add_filter( 'bp_core_fetch_avatar', 'bp_jfb_get_avatar',10,4);

This code should go in a bp-custom.php file and uploaded to the mu-plugins directory.

Skip to toolbar