WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Social Login
WSL Not compatible with BuddyPress - Facebook Login (8 posts)

  1. strongbox
    Member
    Posted 2 years ago #

    When WSL is used on a BuddyPress site and a user chooses to use the Facebook login everything works fine, their profile is created etc.

    The issue is that WSL pulls the persons name from Facebook then inserts it into the database formatted incorrectly. I've used a few other plugins today which did work with BuddyPress without issue.

    If the Facebook name is 'Tom Jones'

    The user table gets:

    user_name = tom_jones

    user_nicename = Tom Jones

    The user_nicename column should only accept all lowercase and no spaces or the profile urls created by buddypress are malformed like http://www.yoursite.com/members/TomJones/profile goes to a 404.

    http://wordpress.org/extend/plugins/wordpress-social-login/

  2. strongbox
    Member
    Posted 2 years ago #

    In plugin.auth.php

    $userdata = array(
    			'user_login'    => $user_login,
    			'user_email'    => $user_email,
    
    			'first_name'    => $hybridauth_user_profile->firstName,
    			'last_name'     => $hybridauth_user_profile->lastName,
    			//'user_nicename' => $hybridauth_user_profile->displayName,
    			'user_nicename' => $hybridauth_user_profile->$user_login,
    			'display_name'  => $hybridauth_user_profile->displayName,
    			'user_url'      => $hybridauth_user_profile->profileURL,
    			'description'   => $hybridauth_user_profile->description,
    
    			'user_pass'     => wp_generate_password()
    		);

    See change made for user_nicename, inserting user login rather than the display_name value which kills buddypress profile links.

    looks like an easy update to the files, the only issue is now we need to update the db to fix previously entered user_nicename values.

  3. strongbox
    Member
    Posted 2 years ago #

    Not sure why I did it the other way, I guess they both work but this method is cleaner I suppose.

    $userdata = array(
    			'user_login'    => $user_login,
    			'user_email'    => $user_email,
    			'user_nicename' => $user_login,
    
    			'first_name'    => $hybridauth_user_profile->firstName,
    			'last_name'     => $hybridauth_user_profile->lastName,
    			//'user_nicename' => $hybridauth_user_profile->displayName,
    			'display_name'  => $hybridauth_user_profile->displayName,
    			'user_url'      => $hybridauth_user_profile->profileURL,
    			'description'   => $hybridauth_user_profile->description,
    
    			'user_pass'     => wp_generate_password()
    		);
  4. strongbox
    Member
    Posted 2 years ago #

    Here is a "final" solution for this issue.

    Since $user_login is already converted to lowercase, however it does insert a "_" if there is a space, I then strip the underscore and make the user_nicename an all one word lowercase slug.

    $user_nicename = trim( str_replace( '_', '', $user_login ) );
    
    		$userdata = array(
    			'user_login'    => $user_login,
    			'user_email'    => $user_email,
    			'user_nicename' => $user_nicename,
    
    			'first_name'    => $hybridauth_user_profile->firstName,
    			'last_name'     => $hybridauth_user_profile->lastName,
    			//'user_nicename' => $hybridauth_user_profile->displayName,
    			'display_name'  => $hybridauth_user_profile->displayName,
    			'user_url'      => $hybridauth_user_profile->profileURL,
    			'description'   => $hybridauth_user_profile->description,
    
    			'user_pass'     => wp_generate_password()
    		);

    This code in the plugin.auth.php file (near the bottom of file) does the trick. Now WSL works with both buddypress and non-buddypress installations as long as you hook WSL into your buddypress registration form.

    Like so:

    # Add WordPress Social Login
    		if (has_filter('activate_wordpress-social-login/wp-social-login.php')) {
    
    		# Login/Registration Button Location
    		add_action ('bp_before_account_details_fields', 'wsl_render_login_form_login'); # Top of registration form
    		//add_action ('bp_before_registration_submit_buttons', 'wsl_render_login_form_login'); # Bottom of registration form
    		}

    This of course should be incorporated into the WSL plugin directly to hook into the BP forms if BP is enabled.

  5. hjmt
    Member
    Posted 1 year ago #

    I am pretty sure i am having the problem you have fixed.

    When someone registers or logs in with WPSL when they try and go through thier profile and other options with buddypress i get 404's.

    Hopefully your fix will solve the problem. Thanks i owe you a beer.

  6. hjmt
    Member
    Posted 1 year ago #

    I actually think the latest update to the pplugin may have fixed this?

  7. strongbox
    Member
    Posted 1 year ago #

    Not sure if they have fixed this in the latest release, haven't looked at the code, but it seems like it should be a very simple fix to implement. It would be nice to not need to hack the code to get it to work with buddypress.

    ;o)

    Maybe the developer will chime in on this?

    P.S. I like micro brews... LOL.

  8. wildhalf
    Member
    Posted 1 year ago #

    Has this been updated to work with buddypress???

    Guess i should give it a try

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic