Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kimwhite/236324b22e189115806f47fd6244b155 to your computer and use it in GitHub Desktop.
Save kimwhite/236324b22e189115806f47fd6244b155 to your computer and use it in GitHub Desktop.
<?php
/**
* This recipe will use custom billing fields and geocode them instead of default
* fields during the checkout process.
*
* Check for the $_REQUEST variable first before checking for the stored user meta.
*
* 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 mypmpromm_custom_address_fields( $member_address, $user_id, $morder ){
$member_address = array(
'street' => '',
'city' => ( !empty( $_REQUEST['city'] ) ) ? $_REQUEST['city'] : get_user_meta( $user_id, 'city', true ),
'zip' => ( !empty( $_REQUEST['zip_code'] ) ) ? $_REQUEST['zip_code'] : get_user_meta( $user_id, 'zip_code', true ),
'country' => '',
);
return $member_address;
}
add_filter( 'pmpromm_member_address_after_checkout', 'mypmpromm_custom_address_fields', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment