Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: xprofile vs usermeta syncing problems


peterverkooijen
Participant

@peterverkooijen

I’m still on 1.1.3. In 1.1.3 xprofile only gets synchronized with wp_usermeta when the user updates his account, which means you can never count on the data being there, which makes it pointless.

Lousy synchronization between xprofile and usermeta is not a bug, it’s a conscious design feature. Why? I’ve brought this issue up many times and have never received a clear answer.

I use a custom function like this below to synchronize member data upon registration into all the different, unconnected places in the database where data is stored:

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);

Not sure if this still works in 1.2. I had posted my work-arounds under ‘FAQ: How To, Code Snippets and Solutions’, but they have been deleted. So I guess they solved the issues in 1.2?

To synch xprofile you’d need to create the fields in xprofile that you have in wp_usermeta and then do something backwards like the above function, if that hook etc. is still valid.

Skip to toolbar