Forked from JarrydLong/mypmpromm-custom-address-fields-profile.php
Last active
November 4, 2022 15:08
-
-
Save kimwhite/be6da2c24cac79c4244106079ed9d060 to your computer and use it in GitHub Desktop.
Edited for Raindrop
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 code recipe references the custom fields you use on your member profiles | |
* to ensure that they are geocoded and not the default billing fields. | |
* | |
* 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_profile_address_fields( $member_address ) { | |
$pmpro_baddress1 = ! empty( $_REQUEST['pmpro_baddress1'] ) ? sanitize_text_field( $_REQUEST['pmpro_baddress1'] ) : ''; | |
$pmpro_baddress2 = ! empty( $_REQUEST['pmpro_baddress2'] ) ? sanitize_text_field( $_REQUEST['pmpro_baddress2'] ) : ''; | |
$pmpro_bcity = ! empty( $_REQUEST['pmpro_bcity'] ) ? sanitize_text_field( $_REQUEST['pmpro_bcity'] ) : ''; | |
$pmpro_bzipcode = ! empty( $_REQUEST['pmpro_bzipcode'] ) ? sanitize_text_field( $_REQUEST['pmpro_bzipcode'] ) : ''; | |
$pmpro_bcountry = ! empty( $_REQUEST['pmpro_bcountry'] ) ? sanitize_text_field( $_REQUEST['pmpro_bcountry'] ) : ''; | |
// If the first address is empty, bail. | |
if ( empty( $pmpro_baddress1 ) ) { | |
return $member_address; | |
} | |
$member_address = array( | |
'street' => $saddress1, | |
'city' => '', | |
'state' => '', | |
'zip' => '' | |
); | |
return $member_address; | |
} | |
add_filter( 'pmpromm_profile_billing_address_fields', 'mypmpromm_profile_address_fields', 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment