• Extremely difficult to submit bugs around here, despite it being designed to be “simple.” Could not find your listing in trac.

    Nevertheless, line 78 of your plugin should be
    if ( !is_user_logged_in() || !$cookie) { ?>

    as users who ARE authenticated, but not registered should still be provided the link to login and allow FB access.

    Overall, fantastic plugin. Thanks for the contribution!

    https://www.ads-software.com/extend/plugins/wp-facebook-connect/

Viewing 15 replies - 16 through 30 (of 75 total)
  • Valentinas, you’re absolutely right. I’m pretty sure this is an issue in the latest version of Safari on OS X 10.6.5. When you sign into a service with Private Browsing on, then later disable it, it won’t let you sign out (or for that matter back in if your session times out). Nothing to do with your plugin, which is awesome by the way. I can’t wait to see how it evolves (hopefully with avatar support ;-).

    Plugin Author valentinas

    (@valentinas)

    markhuot, I just tagged new version (1.2, should show up online soon) with avatar support, check it out!

    Woo! Just tested it and it works great so far. Thanks Valentinas!

    Thanks for the speedy updates. I tested the new version on my BuddyPress site but unfortunately the Avatar still didn’t transfer over. The Logout seemed to work correctly this time, but the avatar didn’t make the cut. Are there any settings in Facebook that must first be changed by the user before permission is granted to transfer the avatar? Any other ideas why this would work for markhuot and not me? Theme specific? Thanks.

    Plugin Author valentinas

    (@valentinas)

    Felzor, avatars only works for regular WP, but not for BP (for now). This is because BP usually has bigger avatars (like in profile page you usually have 100×200 or something) and i haven’t found a way to fetch them from FB nicely. If you are interested in testing I could make a beta version with BP avatars, it’s pretty easy, about 20 lines of code.

    Valentinas: I would be grateful if you could make a beta version with BP avatars. I’d be happy to test out this feature after the Holidays. As long as I can deactivate the plug-in if things don’t work (i.e. it won’t crash the site), since I don’t have backend server access, I don’t mind being your guinea pig in this case. Overall, wonderful work on your part with this plug-in and looking forward to watching it evolve.

    First of valentines, thank you for this plugin. I have latest versions of wordpress and buddypress and just installed your plugin and initially it worked but…I run with couple of errors that I think are all related to the same issue:

    Profile Settings Not AvailableUser who’s login for the 1st time with facebook can not ever access his profile settings. User who makes his account via normal buddypress registration form is able to do so.

    Password Can Not Be ChangedFacebook user can not change his password. Actually he can, but then the new password does not work. From the moment he 1st time use facebook login, he will only be able to login via facebook. Even users who 1st created account using buddypress registration will not be able to successfully change passwords once they login via facebook.

    Add Photo Redirection ErrorI use BP-Album+ for photo album. Users who login with facebook, once they add photo are rederected to site main page in the stead back to album.

    There could be more errors related to the this. I assumed that all of them has something to do with the way your plugin creates names from facebook accounts. WordPress ( thus buddypress ) does not allow capital letters and spaces for account names. Your plugin does. Your plugin should make sure that facebook names are adjusted to wordpress standard: Steve Richardson should be renamed steverichardson before his account is created in word/buddypress.

    I am not sure that’s the problem and solution, this was just my wild guess and i decided to let you know. Again thanks for the plugin but right now I can not use it on my live site due to above. I also don’t know to code PHP so this was the best I could help you with. Looking forward to hear from you and to see the updated version clear from this errors. Also, like she said above, it will be great to fetch users avatars but that’s way down the road, I guess.

    Regards,
    Zoran

    Plugin Author valentinas

    (@valentinas)

    Thanks for feedback, zoran100. It’s very valuable, since the bug related to account names is critical. I was naughty this year and took raw FB name for a user name, when i should’ve sanitized it first. This will be done in next version which will be released in few days.

    Avatars: showstopper here is Facebook (or their lack of documentation on avatars). I will include avatars in next beta release, so you could see for yourself, that will explain better than me.

    Password, profile settings, other stuff is probably related to the username issue. I will let you know once this fixed, so you could test it out.

    Glad I could point to it. I value people who are share their hard work. I wish I could be of more help but like I said, I don’t know how to code in PHP ??

    I’m also almost sure that all other problems are related to that same issue and I can’t wait to test your new version.

    If you wish to go fancy about that, you can give the admin couple of options on how the names will be pulled from the facebook into buddypress. For example 1st option will be that first and last name from facebook becomes one word and that word becomes account name in buddypress. 2nd option that first name from facebook becomes account name and last name from facebook becomes profile name…and vice versa.

    I think that will be of help for different people who setup different web sites on different ways and with different themas but that could be perhaps something for your next version I guess.

    For now, as long as your plugin starts working, I am sure many people will have a great usage for it. Avatar can come even later. If you want me and others to test, just let us know when you post that beta…All the best and Merry Christmas!

    Just one note, maybe important. I just realized that Capital letters are no problem for wordpress…you can enter them anyway if you manually add new users from your admin panel. Why they prohibited new users from doing that on registration is beyond my understanding because all people names start with capital letters. I will se if I can manage to correct that on my site. Anyway, so, you don’t have to change facebook capital letters in your plugin, what messes up wordpress and buddypress are only blank spaces.

    Plugin Author valentinas

    (@valentinas)

    zoran100, turns out that username was good (i did sanitized it before passing to insert_user(); ), but $user->nicename was with a space, so buddypress freaked out. I already fixed that in trunk, will include in next release (next version coming out today or tomorrow)

    Plugin Author valentinas

    (@valentinas)

    zoran100, 1.3 is out and the nicename bug is fixed. If you could try it and let me know if it fixes all the problems you’ve been experiencing, that would be great. Avatars for buddypress coming soon.

    Hello Valentinas, just got the message…I am testing right now will let you know results asap

    OK…It took some time but here are results:

    1st yes! it works! Great job fixing the bug. All errors related to that bug are gone! But there are 2 issues I found that you should know about:

    One: this one is easy. Just like donatien I run into white blank page after upgrade so I changed functions.php to this:

    <?php
    /**
    * facebook_header()
    *
    * @package fb-connect
    * @since 1.0
    *
    * javascript for header
    * taken from here: https://developers.facebook.com/docs/guides/web
    *
    */
    function facebook_header(){
    ?>
    <script src=”https://connect.facebook.net/en_US/all.js”></script&gt;
    <script>
    jQuery(document).ready(function(){
    FB.init({appId: ‘<?php echo FACEBOOK_APP_ID; ?>’, status: true,
    cookie: true, xfbml: true});
    FB.Event.subscribe(‘auth.sessionChange’, function(response) {
    if (response.session) {
    jQuery(‘body’).html(”);
    window.location.href=window.location.href;
    } else {
    jQuery(‘body’).html(”);
    window.location.href=window.location.href;
    }
    });
    });
    </script>
    <?php
    }

    /**
    * fb_logout_url()
    *
    * @package fb-connect
    * @since 1.0
    *
    * logout url for people who are logged in with FB
    *
    */
    function fb_logout_url($url){
    $cookie = get_facebook_cookie(FACEBOOK_APP_ID, FACEBOOK_SECRET);
    if($cookie)
    return “javascript:FB.logout(function(){location.href='” . $url . “‘})”;
    else
    return $url;
    }

    /**
    * fb_footer()
    *
    * @package fb-connect
    * @since 1.0
    *
    * markup for footer
    * taken from here: https://developers.facebook.com/docs/guides/web
    *
    */
    function fb_footer(){
    ?> <div id=”fb-root”></div> <?php
    }

    /**
    * get_facebook_cookie()
    *
    * @package fb-connect
    * @since 1.0
    *
    * gets facebook cookie (yummy thing that is created when user is authenticated with FB in your website)
    * taken from here: https://developers.facebook.com/docs/guides/web
    *
    * @return array|null
    *
    */
    function get_facebook_cookie($app_id, $application_secret) {
    $args = array();
    parse_str(trim($_COOKIE[‘fbs_’ . $app_id], ‘\\”‘), $args);
    ksort($args);
    $payload = ”;
    foreach ($args as $key => $value) {
    if ($key != ‘sig’) {
    $payload .= $key . ‘=’ . $value;
    }
    }
    if (md5($payload . $application_secret) != $args[‘sig’]) {
    return null;
    }
    return $args;
    }

    /**
    * fb_login_user()
    *
    * @package fb-connect
    * @since 1.0
    *
    * this is the main function that performs the login or user creation process
    *
    * @return true
    */
    function fb_login_user(){
    global $wpdb;
    //@todo: investigate: does this gets included doing regular request?
    require_once( ABSPATH . ‘wp-includes/registration.php’ );
    //mmmm, cookie
    $cookie = get_facebook_cookie(FACEBOOK_APP_ID, FACEBOOK_SECRET);
    //if we have cookie, then try to get user data
    if ($cookie) {
    //get user data
    $user = json_decode(@file_get_contents(‘https://graph.facebook.com/me?access_token=&#8217; . $cookie[‘access_token’]));
    //if user data is empty, then nothing will happen
    if( !empty($user) ){
    //this should never happen, since email address is required to register in FB
    //I put it here just in case of API changes or some other disaster, like wrong API key or secret
    if( !isset($user->email) || empty($user->email) ){
    do_action(‘fb_connect_get_email_error’);
    //do not use wp_die here, because it adds styles which can mess up the whole looks of the site
    die(“Error: failed to get your email from Facebook!”);
    }

    //if user is logged in, then we just need to associate FB account with WordPress account
    if( is_user_logged_in() ){
    global $current_user;
    get_currentuserinfo();
    $fb_uid = get_user_meta($current_user->ID, ‘fb_uid’, true);

    if($fb_uid == $user->id)
    return true;

    if( $user->email == $current_user->user_email ) {
    //if FB email is the same as WP email we don’t need to do anything.
    do_action(‘fb_connect_wp_fb_same_email’);
    $fb_uid = get_user_meta($current_user->ID, ‘fb_uid’, true);
    if( !$fb_uid )
    update_user_meta( $current_user->ID, ‘fb_uid’, $user->id );
    return true;
    } else {
    //else we need to set fb_uid in user meta, this will be used to identify this user
    do_action(‘fb_connect_wp_fb_different_email’);
    $fb_uid = get_user_meta($current_user->ID, ‘fb_uid’, true);
    if( !$fb_uid )
    update_user_meta( $current_user->ID, ‘fb_uid’, $user->id );
    $fb_email = get_user_meta($current_user->ID, ‘fb_email’, true);
    if( !$fb_uid )
    update_user_meta( $current_user->ID, ‘fb_email’, $user->email );
    //that’s it, we don’t need to do anything else, because the user is already logged in.
    return true;
    }
    }else{
    //check if user has account in the website. get id
    $existing_user = $wpdb->get_var( ‘SELECT DISTINCT u.ID FROM ' . $wpdb->users . ' u JOIN ' . $wpdb->usermeta . ' m ON u.ID = m.user_id WHERE (m.meta_key = “fb_uid” AND m.meta_value = “‘ . $user->id . ‘” ) OR user_email = “‘ . $user->email . ‘” OR (m.meta_key = “fb_email” AND m.meta_value = “‘ . $user->email . ‘” ) LIMIT 1 ‘ );
    //if the user exists – set cookie, do wp_login, redirect and exit
    if( $existing_user > 0 ){
    $fb_uid = get_user_meta($existing_user, ‘fb_uid’, true);
    if( !$fb_uid )
    update_user_meta( $new_user, ‘fb_uid’, $user->id );
    $user_info = get_userdata($existing_user);
    do_action(‘fb_connect_fb_same_email’);
    wp_set_auth_cookie($existing_user, true, false);
    do_action(‘wp_login’, $user_info->user_login);
    if (wp_get_referer()) {
    wp_redirect(wp_get_referer());
    } else {
    wp_redirect( $_SERVER[‘REQUEST_URI’] );
    }
    exit();
    //if user don’t exist – create one and do all the same stuff: cookie, wp_login, redirect, exit
    } else {
    do_action(‘fb_connect_fb_new_email’);
    //sanitize username
    $username = sanitize_user($user->first_name, true);

    //check if username is taken
    //if so – add something in the end and check again
    $i=”;
    while(username_exists($username . $i)){
    $i=absint($i);
    $i++;
    }

    //this will be new user login name
    $username = $username . $i;

    //put everything in nice array
    $userdata = array(
    ‘user_pass’ => wp_generate_password(),
    ‘user_login’ => $username,
    ‘user_nicename’ => $username,
    ‘user_email’ => $user->email,
    ‘display_name’ => $user->name,
    ‘nickname’ => $username,
    ‘first_name’ => $user->first_name,
    ‘last_name’ => $user->last_name,
    ‘role’ => ‘subscriber’
    );
    $userdata = apply_filters(‘fb_connect_new_userdata’, $userdata, $user);
    //create new user
    $new_user = absint(wp_insert_user($userdata));
    do_action(‘fb_connect_new_user’, $new_user);
    //if user created succesfully – log in and reload
    if( $new_user > 0 ){
    update_user_meta( $new_user, ‘fb_uid’, $user->id );
    $user_info = get_userdata($new_user);
    wp_set_auth_cookie($new_user, true, false);
    do_action(‘wp_login’, $user_info->user_login);
    wp_redirect(wp_get_referer());
    exit();
    } else {
    wp_die(‘Facebook Connect: Error creating new user!’);
    }
    }
    }
    }
    }
    }
    ?>

    so, after that, blank white page was gone. You should change this file in next upgrade as 1st time users will not know to refresh page and that will think that your plugin does not work.

    Second thing:

    This one im not sure how to fix yet: There was a conflinct with another plugin that I have installed before ( took me some time to figure out witch one):

    === AjaxChat ===
    Contributors: Payden Sutherland
    Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=GMXNW6GGYR5LG&lc=US&item_name=Payden%20Sutherland&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted
    Tags: chat, ajax, instant, messaging
    Requires at least: 2.9.2
    Tested up to: 3.0
    Stable Tag: 0.4.2

    ____________________________

    Once I turn off ajaxchat, Facebook Connect started working like a charm! Anyway, here is the error_log that I found in ajaxchat plugin folder related to your plugin:
    _____________________________
    [29-Dec-2010 02:10:53] PHP Parse error: syntax error, unexpected $end in /home/manager1/public_html/wp-content/plugins/wp-facebook-connect/fb-connect.php on line 41
    _____________________________

    I did not try to mess with fb-connect.php line 41, yet but I will try to see if I can figure out how to turn both plugins on. I dont know php but i am advanced vb6 programmer so lets see…

    Anyway,I tought that there could be more plugins on other ppl installations that will create error in your plugin like ajaxchat, so I am letting you know. Other that that, your plugin is now fully funcional. Its actually on right now on one of my brand new sites!

    I will get back here if I fix fb-connect.php line 41 error.
    Again, grat job so far, great plugin, I will vote after this error is cleared highest posible rate!

Viewing 15 replies - 16 through 30 (of 75 total)
  • The topic ‘[Plugin: Facebook Connect] Bug’ is closed to new replies.