it’s not possible out the box at the moment. it may be possible with custom coding but unfortunately that’s not something we can help with.
OK. I’m not good at custom coding… 🙂 But I’m looking for a way to keep fields synched. I’ll post here if find anything.
Thanks @angelo_nwl
Hi! I was able to make it happen with code below inside child-teme function.php:
function sync_xprofile_to_user_meta_one_way_only(){
$user_id = get_current_user_id();
$em_telefone = xprofile_get_field_data( "XPROFILE_PHONE_FIELD_NAME" ,$user_id);
update_user_meta( $user_id, 'dbem_phone', $em_telefone);
}
add_action( 'xprofile_updated_profile', 'sync_xprofile_to_user_meta_one_way_only', 10, 0 );
add_action( 'bp_core_signup_user', 'sync_xprofile_to_user_meta_one_way_only', 10, 0 );
add_action( 'bp_core_activated_user', 'sync_xprofile_to_user_meta_one_way_only', 10, 0 );
Thanks for sharing your code; it might help someone else.
Hello @mauromello,
Nice! that’s just what I need. But your phone field is XPROFILE_PHONE_FIELD_NAME ??
And how do you check it’s working? through the wordpress profile field or through an em action (like sending new booking email to admin)…
Thanks in advance.
Hugo
-
This reply was modified 7 years, 7 months ago by Hugo64.
Hi @hugobernard
XPROFILE_PHONE_FIELD_NAME is just a generic name. You should use your field name.
I just checked once looking user profile to check it’s working. But you can improve it writing to log or any other action you like…
Let me know if you improve this code…
-
This reply was modified 7 years, 7 months ago by Mauro Mello.
-
This reply was modified 7 years, 7 months ago by Mauro Mello.
Hey @mauromello,
Thanks for answering, I put it and nothing happened. my field name is “Movil”. Maybe should I put something else I don’t know. Working on it… but if you have an idea… 😉
Cheers
@hugobernard
Below is my full code
function sync_xprofile_to_user_meta_one_way_only(){
$user_id = get_current_user_id();
$bp_telefone = xprofile_get_field_data( "Telefone" ,$user_id);
$bp_whatsapp = xprofile_get_field_data( "Whatsapp" ,$user_id);
if (!empty($bp_whatsapp)) :
$em_telefone = $bp_telefone . ' / ' . $bp_whatsapp;
else :
$em_telefone = $bp_telefone;
endif;
update_user_meta( $user_id, 'dbem_phone', $em_telefone);
}
add_action( 'xprofile_updated_profile', 'sync_xprofile_to_user_meta_one_way_only', 10, 0 );
add_action( 'bp_core_signup_user', 'sync_xprofile_to_user_meta_one_way_only', 10, 0 );
add_action( 'bp_core_activated_user', 'sync_xprofile_to_user_meta_one_way_only', 10, 0 );
I don’t know why, but looks like only the ‘xprofile_updated_profile’ action is working… Try to update the profile and check if the field is updated..