Created
January 13, 2022 11:23
-
-
Save JarrydLong/fbadb4d0eae1e41b942dd43fb5adf0d2 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 //do not copy | |
/** | |
* This recipe will automatically populate the PMPro checkout fields Woocommerce field data. | |
* | |
* You can add this recipe to your site by creating a custom plugin | |
* or using the Code Snippets plugin available for free in the WordPress repository. | |
* Read this companion article for step-by-step directions on either method. | |
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
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' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment