Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor M66B

    (@m66b)

    I have never used BuddyPress, but I will take a look if I can realize this.

    Plugin Contributor M66B

    (@m66b)

    As far as I can see BuddyPress is using the WordPress user data, so BrowserID should work for BuddyPress like it works for WordPress.

    Note that BrowserID does not create WordPress user accounts. It merely logs in using the verified e-mail address of the user (that is what BrowserID is about).

    Ok there is one problem though. If a user is not already registered to a wordpress site with their email, the BrowserID login will fail, because it looks for the corresponding email in the wordpress database. Upon not finding it, it gives a “fail” error message.
    In order to make the user experience more smooth, it would be a very very good idea to register a user who attempts to login to the wordpress site for the first time using BrowserID, if they are not already registered, in order to avoid a “fail” error message which in the end obliges them to register to the wordpress site anyway.

    So in order to get around this obstacle, I added a few lines of code to the plugin, I added an “else” condition in the function “Login_by_email()” which registers a new user with a random password and using the first part of the email address as username, when this email is not yet registered to the wordpress website:

    // Login user using e-mail address
    function Login_by_email($email, $rememberme) {
    	global $user;
    	$user = null;
    
    	$userdata = get_user_by('email', $email);
    	if ($userdata) {
    		$user = new WP_User($userdata->ID);
    		wp_set_current_user($userdata->ID, $userdata->user_login);
    		wp_set_auth_cookie($userdata->ID, $rememberme);
    		do_action('wp_login', $userdata->user_login);
    	}
    	else{
    		$random_password = wp_generate_password(12, false);
    	        $user_name= explode("@",$email);
    		wp_create_user($user_name[0], $random_password, $email);
    		$user = self::Login_by_email($email, $rememberme);
    	}
    	return $user;
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Mozilla BrowserID] buddypress?’ is closed to new replies.