Last active
June 19, 2024 11:46
-
-
Save plugin-republic/d2d36d2a38897d968a133b24422dd157 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get the user's location and populate the address | |
*/ | |
function prefix_created_customer( $user_id ) { | |
// Lcoation field ID | |
$field_id = '4171f87f'; | |
// Get the location | |
$main_account_id = get_user_meta( $user_id, $field_id, true ); | |
// Get the main billing address | |
$address_fields = array( | |
'billing_company', | |
'billing_address_1', | |
'billing_address_2', | |
'billing_city', | |
'billing_state', | |
'billing_country', | |
'billing_postcode', | |
'billing_phone', | |
'shipping_company', | |
'shipping_address_1', | |
'shipping_address_2', | |
'shipping_city', | |
'shipping_state', | |
'shipping_country', | |
'shipping_postcode', | |
'shipping_phone' | |
); | |
foreach( $address_fields as $address_field ) { | |
$address_item = get_user_meta( $main_account_id, $address_field, true ); | |
update_user_meta( $user_id, $address_field, $address_item ); | |
} | |
} | |
add_action( 'woocommerce_created_customer', 'prefix_created_customer', 1000 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment