Sync billing first and last name to the user profile in WooCommerce

Sync billing first and last name to the user profile in WooCommerce on child sites.

Snippet Type

Execute on Child Sites

Snippet

add_filter( 'pre_user_first_name', 'wc_sync_user_edit_profile_edit_billing_first_name' );
 
function wc_sync_user_edit_profile_edit_billing_first_name( $first_name ) {
    if ( isset( $_POST['billing_first_name'] ) ) {
        $first_name = $_POST['billing_first_name'];
    }
    return $first_name;
}
 
add_filter( 'pre_user_last_name', 'wc_sync_user_edit_profile_edit_billing_last_name' );
 
function wc_sync_user_edit_profile_edit_billing_last_name( $last_name ) {
    if ( isset( $_POST['billing_last_name'] ) ) {
        $last_name = $_POST['billing_last_name'];
    }
    return $last_name;
}
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.