0

Is ther a way of displaying the facebook profile picture in the WP-FB AutoConnect widget?

Like the bbPress login widget:

enter image description here

The WP-FB AutoConnect widget doesn't show it (I think it is like this by default):

enter image description here

(I'm using the latest version of the plugin + Wordpress 3.1 + bbpress plugin (also the latest version).

2 Answers 2

1

Hi JanoChen,

WP-FP-AutoConnect create a function that gets the Facebook Profile image and outputs it as an avatar.

The function is jfb_wp_avatar and it can be added to your template.

You have to enable the option in the plugin settings.

Here is how the function is defined in the plugin:

/**
  * Optionally replace WORDPRESS avatars with FACEBOOK profile pictures
  */
if( get_option($opt_jfb_wp_avatars) ) add_filter('get_avatar', 'jfb_wp_avatar', 10, 5);
function jfb_wp_avatar($avatar, $id_or_email, $size, $default, $alt)
{
    //First, get the userid
    if (is_numeric($id_or_email))       
        $user_id = $id_or_email;
    else if(is_object($id_or_email) && !empty($id_or_email->user_id))
       $user_id = $id_or_email->user_id;
    else if(is_string($id_or_email))
       $user_id = get_user_by('email', $id_or_email ); 

    //If we couldn't get the userID, just return default behavior (email-based gravatar, etc)
    if(!isset($user_id) || !$user_id) return $avatar;

    //Now that we have a userID, let's see if we have their facebook profile pic stored in usermeta
    $fb_img = get_usermeta($user_id, 'facebook_avatar_thumb');
    
    //If so, replace the avatar! Otherwise, fallback on what WP core already gave us.
    if($fb_img) $avatar = "<img alt='fb_avatar' src='$fb_img' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
    return $avatar;
}
1
  • How do you exactly call this function again? I tried <?php echo jfb_wp_avatar(); ?> and <?php echo jfb_wp_avatar($avatar, $id_or_email, $size, $default, $alt); ?>, but doesn't work. Sep 23, 2011 at 8:13
0

Check the plugin's settings or the widget settings. The page of WP-FB AutoConnect in the official WordPress plugin directory says:

Facebook profile pictures can be used as avatars, even on pre-existing comments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.