Skip to:

WordPress to BuddyPress profile sync

  • krioteh


    In BuddyPress there is a built-in mechanism for synchronizing profile fields from WordPress.
    By default, it synchronizes only the “display_name” field, which is not always sufficient.
    Here is an example of the code by which you can synchronize any available fields in the WordPress field with the Buddypress fields

    function xprofile_sync_bp_profile2( &$errors, $update, &$user ) {
    	// Bail if profile syncing is disabled.
    	if ( bp_disable_profile_sync() || ! $update || $errors->get_error_codes() ) {
        // Querying data from a table "usermeta", first we get the value of the custom field "address" and substitute this value for the "Address" field of the xprofile BuddyPress
        $address = get_user_meta( $user->ID, 'address', 'true' );  
    	xprofile_set_field_data( 'Address', $user->ID, $address );
      	//Similarly with other fields
        $firstname = get_user_meta( $user->ID, 'first_name', 'true' );  
    	xprofile_set_field_data( 'Name', $user->ID, $firstname );
      	$lastname = get_user_meta( $user->ID, 'last_name', 'true' );  
    	xprofile_set_field_data( 'Lastname', $user->ID, $lastname );
      	$description = get_user_meta( $user->ID, 'description', 'true' );  
    	xprofile_set_field_data( 'Bio', $user->ID, $description );
      	// Querying data from a table "user"
        xprofile_set_field_data( 'E-mail', $user->ID, $user->user_email );
        xprofile_set_field_data( 'Site', $user->ID, $user->user_url );
    add_action( 'user_profile_update_errors', 'xprofile_sync_bp_profile2', 10, 3 );

    Unfortunately, the fields are synchronized only when the profile is updated. I do not know how to start mass synchronization 🙁

    I hope someone will find this information useful.

Viewing 6 replies - 1 through 6 (of 6 total)

  • krioteh


    Nobody knows how to run a massive update of user profiles in the WordPress?
    Sadness … 🙁

    Henry Wright


    Unfortunately, the fields are synchronized only when the profile is updated. I do not know how to start mass synchronization

    This is likely because you’re hooking to a hook fired at profile update. You’ll need to hook your code to something that gets fired at another point in time.



    I, like that dog: I understand everything – I can not say 🙂

    I just made changes to the standard BuddyPress function, there was this hook.
    I think that I need to call a loop, which in turn will sort through all the users and start synchronization in this cycle. Then add this cycle to the crowns so that the synchronization is done according to the schedule.

    But how to translate this into php …
    Ok, I’ll go and smoke the manuals. Thanks for the tip-off.

    Norman Cates


    That’s awesome.

    Why is this not a standard part of Buddypress? (Rhetorical question)

    IMO, any fields should be designated (or able to be designated) as linked to the WP profile information.

    THis is a CONSTANT source of confusion for me and any users. Because some plugins use the WordPress profile info, and some the Buddypress info.

    I get that they probably need to do that. But at least let us synchronise the data.

    Including display name options…

    Please, BP / WP developers, slam an interface on this and let us keep our data consistent.




    @normancates, BuddyPress has an only primary field as Name, rest are user-defined.
    With BuddyPress, you are also allowed to create additional First Name & Last Name fields, and it will need some custom codes like pasted by @krioteh.

    You can try, hopefully, it will help.

    Vitor Chaves


    Does this code still work?

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Skip to toolbar