WordPress.org

Ready to get started?Download WordPress

Forums

Add Link to Facebook
[resolved] automatically login after facebook registration (8 posts)

  1. Peidong Hu
    Member
    Posted 1 year ago #

    Current registration won't automatically login, add the following code in function static function Facebook_registration() will do the work, (after this piece of code,
    // Redirect
    if ($user_ID) {
    update_user_meta($user_ID, c_al2fb_meta_facebook_id, $me->id);
    $url = get_user_meta($user_ID, c_al2fb_meta_reg_success, true);
    if (empty($url))
    {
    )
    =========================
    //phu fix bug of multisite wrong meta facebook id
    $c_al2fb_meta_facebook_id = c_al2fb_meta_facebook_id;

    if (is_multisite()) {
    global $blog_id;
    $c_al2fb_meta_facebook_id = "blog_".$blog_id."_".$c_al2fb_meta_facebook_id;
    }

    // Workaround if no e-mail present
    if (!empty($me) && empty($me->email)) {
    $users = get_users(array(
    'meta_key' => $c_al2fb_meta_facebook_id,
    'meta_value' => $me->id
    ));
    if (count($users) == 0) {
    $regurl = get_user_meta($_REQUEST['user'], c_al2fb_meta_login_regurl, true);
    if (!empty($regurl))
    wp_redirect($regurl);
    }
    else if (count($users) == 1)
    $me->email = $users[0]->user_email;
    }

    // Check Facebook user
    if (!empty($me) && !empty($me->id)) {
    // Find user by Facebook ID
    $users = get_users(array(
    'meta_key' => $c_al2fb_meta_facebook_id,
    'meta_value' => $me->id
    ));

    // Check if found one
    if (count($users) == 1) {
    // Try to login
    $user = WPAL2Int::Login_by_email($users[0]->user_email, true);

    // Check login
    if ($user) {
    // Persist token
    update_user_meta($user->ID, c_al2fb_meta_facebook_token, $_REQUEST['token']);
    update_user_meta($user->ID, c_al2fb_meta_facebook_token_time, time());

    // Redirect
    $self = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_REQUEST['uri'];
    $redir = get_user_meta($_REQUEST['user'], c_al2fb_meta_login_redir, true);
    $url = $redir ? $redir : $self;
    }
    } else {
    $url = get_home_url();
    }
    }

    http://wordpress.org/extend/plugins/add-link-to-facebook/

  2. Marcel Bokhorst
    Member
    Plugin Author

    Posted 1 year ago #

    This should not be necessary, look in add-link-to-facebook.php and you'll see the meta names for multi-sites are filtered.

  3. Peidong Hu
    Member
    Posted 1 year ago #

    marcel, r u talking about the meta name issue or auto login issue?

  4. Marcel Bokhorst
    Member
    Plugin Author

    Posted 1 year ago #

    I was talking about the meta name issue.
    Logging in after registration is not desirable, since the Facebook session timeout is quite short.

  5. Peidong Hu
    Member
    Posted 1 year ago #

    As I tested, Facebook session WON'T timeout after even 7 hours. How come do you say it's short?

  6. Marcel Bokhorst
    Member
    Plugin Author

    Posted 1 year ago #

    Did you test with an access token acquired using the Facebook Client-side Login flow? These tokens are short living for security reasons, in contrary to tokens acquired with the Facebook Server-side Login flow.

  7. Peidong Hu
    Member
    Posted 1 year ago #

    oh. I c. you were taking about the auth token. However, I was testing it from a end user view point. The user account registered through Add Link to Facebook plugin will keeps alive on both sites for long time actually even the auth access token is short-live.

    And it's really user-friendly with this feature.

    You can try on hu-shanqi.com which has been modified to directly Login after facebook-registeration work flow.

    Peidong

  8. Marcel Bokhorst
    Member
    Plugin Author

    Posted 1 year ago #

    Send me a patch based on the latest version through this contact form and I will include this in the next release.

    How to make a patch:
    - install subversion
    - svn co http://plugins.svn.wordpress.org/add-link-to-facebook
    - make/test your changes
    - svn diff

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.