• Resolved Anonymous User 16833488

    (@anonymized-16833488)


    Buddypress uses custom registration fields, called xProfile, and they are not synchronized with the WordPress profile fields.
    Therefore, when a user logs in using some social network the xProfile fields are not filled, the wordpress ones are.

    wp: https://prntscr.com/octqze
    xprofile: https://prntscr.com/octr4v

    Does this plugin have some function to auto populate both fields when the user uses the social login option?

    Many thanks for your plugin!

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Anonymous User 16833488

    (@anonymized-16833488)

    I found in a buddypress file a function that does exactly what I quoted, but I guess it does not run after login using the nextend…

    function xprofile_sync_bp_profile( &$errors, $update, &$user ) {
    
    	// Bail if profile syncing is disabled.
    	if ( bp_disable_profile_sync() || ! $update || $errors->get_error_codes() ) {
    		return;
    	}
    
    	if ( isset( $user->first_name ) ) {
    		xprofile_set_field_data( bp_xprofile_firstname_field_id(), $user->ID, $user->first_name );
    	}
    
    	if ( isset( $user->last_name ) ) {
    		xprofile_set_field_data( bp_xprofile_lastname_field_id(),  $user->ID, $user->last_name );
    	}
    
    	if ( isset( $user->nickname ) ) {
    		xprofile_set_field_data( bp_xprofile_nickname_field_id(),  $user->ID, $user->nickname );
    	}
    
    	$user->display_name = bp_custom_display_name_format( $user->display_name, $user->ID );
    }
    add_action( 'user_profile_update_errors', 'xprofile_sync_bp_profile', 20, 3 );

    I do not understand much of programming but from what I researched, this function will only be executed when updating a profile manually in the wordpress panel. So what would be necessary to run it shortly after logging in with nextend? Is there any way to do this?

    Plugin Support Laszlo

    (@laszloszalvak)

    Hi @fabianski

    I am sorry, but we don’t have any integrations for synchronizing the custom profile fields. It is something what you can only achieve with custom coding, since most of the profile fields are created by the owner of the site at:
    WordPress side bar > Users > Profile fields

    Anyway we can give you some hints and tips what would probably work for you:
    -we have actions where you can hook custom functions:
    https://nextendweb.com/nextend-social-login-docs/backend-developer/
    the action you are looking for is called “nsl_register_new_user”
    The functions that are hooked to this action, will be triggered each time a user is registered with one of the social providers.

    So you should write a custom function in which you get the user by the ID what is provided by Nextend Social Login and then you could synchronize the user data, with the custom xprofile field you need.

    Here is a basic example code for hooking a function to this action:

    function yourCustomFunctionName($user_id, $provider) {
        $wp_user_object = new WP_User($user_id);
        //your custom code to synchronize the data
    }
    add_action('nsl_register_new_user', 'yourCustomFunctionName', 10, 2);
    

    You could give their “xprofile_set_field_data” function a try, since with that you can set profile data for a specific field for a specific user.
    If that wouldn’t work, I would suggest getting in touch with the developers of BuddyPress, they can probably provide you more clear information the xprofile functions you need to use.

    Best regards,
    Laszlo.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Buddypress xProfiles’ is closed to new replies.