Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Am able to use the following function POST registration.

But would like to achieve same ON registration.

So just a visit to the edit profile tab triggers the function below.

function copyUserMeta() {
    global $current_user;
    $user_id = $current_user->ID;
    $firstname = xprofile_get_field_data( "First Name" ,$user_id);
    update_user_meta( $user_id, 'first_name',$firstname);
add_action('bp_before_profile_edit_content', 'copyUserMeta');`

So CHANGES to the profile fields are reflected in the usermeta.

But would like also to have the fields copied to usermeta ON registration.

Had been using successfully a solution shown at http://buddypress.org/support/topic/xprofile-vs-usermeta-syncing-problems/ (with add_action( 'wpmu_activate_user', 'synchro_wp_usermeta', 10, 3);), but for some reason it no longer functions.

A potential workaround could be on first login go/redirect to members/userxprofile/edit/group/1/, though I would prefer the straightforward copy profile fields to usermeta on registration.

There is also a function add_user_meta()?

Background:- can/will research, can/will follow instructions but quite limited at coding. At the moment doing this on local installs.

Ideas, potential solutions very very welcome?

share|improve this question
add comment

1 Answer

On registration, a bp_core_signup_user action hook is fired, which pass a $usermeta array to the action functions, and that array contains all profile fields data that you can utilize to synchronize BP profile with WP profile data:

add_action('bp_core_signup_user', 'ad_user_signup_usermeta', 10, 5);
function ad_user_signup_usermeta($user_id, $user_login, $user_password, $user_email, $usermeta) {

    // you need to know the field_id of the "First Name" field
    // one way to find out what is the field_id of the "First Name" field:
    // echo '<pre>' . print_r($usermeta, 1) . '</pre>'; die();
    // if the field_id, for example, was "field_2":

    update_user_meta($user_id, 'first_name', $usermeta['field_2']);

add_user_meta() function will be called through update_user_meta() if meta_key was not found in the database. So you can just use update_user_meta() for almost all cases.

share|improve this answer
Many Thanks for editing and for the above. Unfortunately, inserting the above in functions.php of theme did not transfer the data to usermeta. and yet just a visit to the profile/edit/group/1/ effects the transfer with the other function. –  Valentine Cosgrave Dec 19 '12 at 16:21
I have tested the code on my local installation and it is working properly. Did replace the field_2 with the one that represent the field_id of "First Name" field on your installation? –  Ahmad M Dec 19 '12 at 16:37
Afraid i have succumbed to the conditional redirect solution Many thanks all the same. –  Valentine Cosgrave Dec 19 '12 at 18:26
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.