Code-Snippets-Functions/Execute a function on a child site/Paid Memberships Pro/autofill-billing-fields-from-woocommerce.txt

30 lines
1.3 KiB
Text

function mypmpro_autofill_pmpro_fields() {
global $current_user, $bfirstname, $blastname, $baddress1, $baddress2, $bcity, $bstate, $bzipcode, $bcountry, $bphone;
// Personal details from billing details WooCommerce.
$company = get_user_meta( $current_user->ID, 'billing_company', true );
$fname = get_user_meta( $current_user->ID, 'billing_first_name', true );
$lname = get_user_meta( $current_user->ID, 'billing_last_name', true );
$phone = get_user_meta( $current_user->ID, 'billing_phone', true );
// Address details from billing details WooCommerce.
$address_1 = get_user_meta( $current_user->ID, 'billing_address_1', true );
$address_2 = get_user_meta( $current_user->ID, 'billing_address_2', true );
$city = get_user_meta( $current_user->ID, 'billing_city', true );
$state = get_user_meta( $current_user->ID, 'billing_state', true );
$postcode = get_user_meta( $current_user->ID, 'billing_postcode', true );
$country = get_user_meta( $current_user->ID, 'billing_country', true );
$bfirstname = $fname;
$blastname = $lname;
$baddress1 = $address_1;
$baddress2 = $address_2;
$bcity = $city;
$bstate = $state;
$bzipcode = $postcode;
$bcountry = $country;
$bphone = $phone;
}
add_action( 'wp', 'mypmpro_autofill_pmpro_fields' );