Skip to:
Content
Pages
Categories
Search
Top
Bottom

Automatically (on register) copy xprofile data to wp_usermeta -Success ! but one little tweak needed

  • @valuser

    Participant

    not by my own labour!

    Found this code that copies profile field data to usermeta fields at http://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/xprofile-vs-usermeta-syncing-problems/

    `function synchro_wp_usermeta($user_id, $password, $meta) {
    global $bp, $wpdb;

    $uid = get_userdata($user_id);
    $email = $uid->user_email;

    $fullname = $meta[field_1];

    … whatever you need here ….

    update_usermeta( $user_id, ‘nickname’, $fullname );
    update_usermeta( $user_id, ‘first_name’, $firstname );
    update_usermeta( $user_id, ‘last_name’, $lastname );

    $wpdb->query( $wpdb->prepare( “UPDATE {$wpdb->users} SET display_name = %s WHERE ID = %d”, $fullname, $user_id ) );
    $wpdb->query( $wpdb->prepare( “UPDATE {$wpdb->users} SET user_url = %s WHERE ID = %d”, bp_core_get_user_domain( $user_id ), $user_id ) );
    }
    add_action( ‘wpmu_activate_user’, ‘synchro_wp_usermeta’, 10, 3);`

    Have tested it and it does copy data from xprofile field to wp_usermeta field.

    The line above
    `$fullname = $meta[field_1];`

    refers to the id number of the field in wp_XX_bp_xprofile_fields (where XX is the site id number).

    I want to use the field name here, not the number.

    what do I change `$fullname = $meta[field_1];` to use the field name ? Please.

  • The topic ‘Automatically (on register) copy xprofile data to wp_usermeta -Success ! but one little tweak needed’ is closed to new replies.
Skip to toolbar