WordPress.org

Ready to get started?Download WordPress

Forums

Mozilla Persona (BrowserID)
[Plugin: Mozilla BrowserID] buddypress? (4 posts)

  1. kb_unhammer
    Member
    Posted 2 years ago #

    Could this be made to work with buddypress? I guess some sort of wordpress user account needs to be created for each new user signing in with browserid (like the wp-facebook autoconnect thing does – I'd love to be able to ditch that and use browserid only =D).

    http://wordpress.org/extend/plugins/browserid/

  2. Marcel Bokhorst
    Member
    Plugin Author

    Posted 2 years ago #

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

  3. Marcel Bokhorst
    Member
    Plugin Author

    Posted 2 years ago #

    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).

  4. Lwangaman
    Member
    Posted 1 year ago #

    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;
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags