How to update billing_email when user_email is updated [closed]

This code should do it for you. It add an action to the updating of the WordPress profile, checks if the email has been updated, and if so, it updates the Woocommerce address as well.

add_action('profile_update', 'sync_woocommerce_email', 10, 2) ;

function sync_woocommerce_email( $user_id, $old_user_data ) {
    $current_user = wp_get_current_user();

    if ($current_user->user_email != $old_user_data->user_email) {
        wp_update_user( array ( 'ID' => $current_user->ID, 'billing_email' => $current_user->user_email ) ) ;
     }
}

Edit: I did something wrong here, I’m guessing its pretty basic I just haven’t seen it yet.