Created
May 24, 2022 12:54
-
-
Save igorbenic/a439dedc37f5453ec404d299f96a1346 to your computer and use it in GitHub Desktop.
RCP New Fields
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 | |
add_action( 'rcp_after_password_registration_field', 'rcp_my_custom_address_fields' ); | |
function rcp_my_custom_address_fields() { | |
?> | |
<p id="rcp_address_country"> | |
<label for="rcp_address_country">Country</label> | |
<input name="rcp_address_country" id="rcp_address_country" type="text"/> | |
</p> | |
<p id="rcp_address_line_1"> | |
<label for="rcp_address_line_1">Address Line 1</label> | |
<input name="rcp_address_line_1" id="rcp_address_line_1" class="required" type="text"/> | |
</p> | |
<p id="rcp_address_line_2"> | |
<label for="rcp_address_line_2">Address Line 2</label> | |
<input name="rcp_address_line_2" id="rcp_address_line_2" type="text"/> | |
</p> | |
<p id="rcp_address_city"> | |
<label for="rcp_address_city">City</label> | |
<input name="rcp_address_city" id="rcp_address_city" type="text"/> | |
</p> | |
<p id="rcp_address_state"> | |
<label for="rcp_address_state">State</label> | |
<input name="rcp_address_state" id="rcp_address_state" type="text"/> | |
</p> | |
<p id="rcp_address_postcode"> | |
<label for="rcp_address_postcode">Postal Code</label> | |
<input name="rcp_address_postcode" id="rcp_address_postcode" type="text"/> | |
</p> | |
<?php | |
} |
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 | |
// Save Data | |
add_action( 'rcp_form_processing', 'rcp_save_my_custom_addresses', 20, 2); | |
function rcp_save_my_custom_addresses( $posted_data, $user_id ) { | |
if ( ! empty( $posted_data['rcp_address_country'] ) { | |
update_user_meta( $user_id, 'rcp_address_country', sanitize_text_field( $posted_data['rcp_address_country'] ) ); | |
} | |
if ( ! empty( $posted_data['rcp_address_line_1'] ) { | |
update_user_meta( $user_id, 'rcp_address_line_1', sanitize_text_field( $posted_data['rcp_address_line_1'] ) ); | |
} | |
if ( ! empty( $posted_data['rcp_address_line_2'] ) { | |
update_user_meta( $user_id, 'rcp_address_line_2', sanitize_text_field( $posted_data['rcp_address_line_2'] ) ); | |
} | |
if ( ! empty( $posted_data['rcp_address_city'] ) { | |
update_user_meta( $user_id, 'rcp_address_city', sanitize_text_field( $posted_data['rcp_address_city'] ) ); | |
} | |
if ( ! empty( $posted_data['rcp_address_state'] ) { | |
update_user_meta( $user_id, 'rcp_address_state', sanitize_text_field( $posted_data['rcp_address_state'] ) ); | |
} | |
if ( ! empty( $posted_data['rcp_address_postcode'] ) { | |
update_user_meta( $user_id, 'rcp_address_postcode', sanitize_text_field( $posted_data['rcp_address_postcode'] ) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment