I need to automatically update WooCommerce billing email after any user updates its WP account email. I rebuilt this function for this:
/* Update woocommerce billing email based on account email */
add_filter( 'profile_update' , 'custom_update_billing_email', 10, 2 );
function custom_update_billing_email($user_id, $old_user_data ) {
$current_user = wp_get_current_user();
// Updating Billing info
if($current_user->billing_email != $current_user->user_email)
update_user_meta($user_id, 'user_email', $current_user->billing_email);
}
Please advise if all is fine since to test the function I’ll need to make actual orders on the site.