Skip to content

Instantly share code, notes, and snippets.

@ameeker
Created August 7, 2014 17:11
Show Gist options
  • Save ameeker/c08e566568a408a34b58 to your computer and use it in GitHub Desktop.
Save ameeker/c08e566568a408a34b58 to your computer and use it in GitHub Desktop.
rcp custom fields
<?php
/*
Plugin Name: Restrict Content Pro - Custom User Fields
Description: Adds additional user fields to the registration process
Version: 1.0
Author: Pippin Williamson
Author URI: http://pippinsplugins.com
Contributors: mordauk, angiemeeker
*/
/**
* Adds the custom fields to the registration form and profile editor
*
*/
function pw_rcp_add_user_fields() {
$address = get_user_meta( get_current_user_id(), 'rcp_address', true );
$city = get_user_meta( get_current_user_id(), 'rcp_city', true );
$state = get_user_meta( get_current_user_id(), 'rcp_state', true );
$zip = get_user_meta( get_current_user_id(), 'rcp_zip', true );
$phone = get_user_meta( get_current_user_id(), 'rcp_phone', true );
$company_organization = get_user_meta( get_current_user_id(), 'rcp_company_organization', true );
$title = get_user_meta( get_current_user_id(), 'rcp_title', true );
$other_membership = get_user_meta( get_current_user_id(), 'rcp_other_membership', true );
$univ_1 = get_user_meta( get_current_user_id(), 'rcp_univ_1', true );
$univ_1_major = get_user_meta( get_current_user_id(), 'rcp_univ_1_major', true );
$univ_1_degree = get_user_meta( get_current_user_id(), 'rcp_univ_1_degree', true );
$univ_1_year = get_user_meta( get_current_user_id(), 'rcp_univ_1_year', true );
$univ_2 = get_user_meta( get_current_user_id(), 'rcp_univ_2', true );
$univ_2_major = get_user_meta( get_current_user_id(), 'rcp_univ_2_major', true );
$univ_2_degree = get_user_meta( get_current_user_id(), 'rcp_univ_2_degree', true );
$univ_2_year = get_user_meta( get_current_user_id(), 'rcp_univ_2_year', true );
$univ_3 = get_user_meta( get_current_user_id(), 'rcp_univ_3', true );
$univ_3_major = get_user_meta( get_current_user_id(), 'rcp_univ_3_major', true );
$univ_3_degree = get_user_meta( get_current_user_id(), 'rcp_univ_3_degree', true );
$univ_3_year = get_user_meta( get_current_user_id(), 'rcp_univ_3_year', true );
?>
<div class="contact">
<legend>Contact Information</legend>
<p>
<label for="rcp_address"><?php _e( 'Street Address', 'rcp' ); ?></label>
<input name="rcp_address" id="rcp_address" type="text" value="<?php echo esc_attr( $address ); ?>"/>
</p>
<p>
<label for="rcp_state"><?php _e( 'State', 'rcp' ); ?></label>
<input name="rcp_state" id="rcp_state" type="text" value="<?php echo esc_attr( $state ); ?>"/>
</p>
<p>
<label for="rcp_city"><?php _e( 'City', 'rcp' ); ?></label>
<input name="rcp_city" id="rcp_city" type="text" value="<?php echo esc_attr( $city ); ?>"/>
</p>
<p>
<label for="rcp_zip"><?php _e( 'Zip', 'rcp' ); ?></label>
<input name="rcp_zip" id="rcp_zip" type="text" value="<?php echo esc_attr( $zip ); ?>"/>
</p>
<p>
<label for="rcp_phone"><?php _e( 'Phone', 'rcp' ); ?></label>
<input name="rcp_phone" id="rcp_phone" type="text" value="<?php echo esc_attr( $phone ); ?>"/>
</div>
</p>
<div class="experience">
<legend>Experience</legend>
<p>
<label for="rcp_company_organization"><?php _e( 'Company or Organization', 'rcp' ); ?></label>
<input name="rcp_company_organization" id="rcp_company_organization" type="text" value="<?php echo esc_attr( $company_organization ); ?>"/>
</p>
<p>
<label for="rcp_title"><?php _e( 'Title', 'rcp' ); ?></label>
<input name="rcp_title" id="rcp_title" type="text" value="<?php echo esc_attr( $title ); ?>"/>
</p>
<p>
<label for="rcp_other_membership"><?php _e( 'Other Memberships', 'rcp' ); ?></label>
<input name="rcp_other_membership" id="rcp_other_membership" type="text" value="<?php echo esc_attr( $other_membership ); ?>"/>
</div>
</p>
<div class="education">
<legend>Education</legend>
<div class="ed_fields">
<p>
<label for="rcp_univ_1"><?php _e( 'University', 'rcp' ); ?></label>
<input name="rcp_univ_1" id="rcp_univ_1" type="text" value="<?php echo esc_attr( $univ_1 ); ?>"/>
</p>
<p>
<label for="rcp_univ_1_major"><?php _e( 'Major', 'rcp' ); ?></label>
<input name="rcp_univ_1_major" id="rcp_univ_1_major" type="text" value="<?php echo esc_attr( $univ_1_major ); ?>"/>
</p>
<p>
<label for="rcp_univ_1_degree"><?php _e( 'Degree', 'rcp' ); ?></label>
<input name="rcp_univ_1_degree" id="rcp_univ_1_degree" type="text" value="<?php echo esc_attr( $univ_1_degree ); ?>"/>
</p>
<p>
<label for="rcp_univ_1_year"><?php _e( 'Year Graduated', 'rcp' ); ?></label>
<input name="rcp_univ_1_year" id="rcp_univ_1_year" type="text" value="<?php echo esc_attr( $univ_1_year ); ?>"/>
</p>
</div>
<div class="ed_fields">
<p>
<label for="rcp_univ_2"><?php _e( 'University', 'rcp' ); ?></label>
<input name="rcp_univ_2" id="rcp_univ_2" type="text" value="<?php echo esc_attr( $univ_2 ); ?>"/>
</p>
<p>
<label for="rcp_univ_2_major"><?php _e( 'Major', 'rcp' ); ?></label>
<input name="rcp_univ_2_major" id="rcp_univ_2_major" type="text" value="<?php echo esc_attr( $univ_2_major ); ?>"/>
</p>
<p>
<label for="rcp_univ_2_degree"><?php _e( 'Degree', 'rcp' ); ?></label>
<input name="rcp_univ_2_degree" id="rcp_univ_2_degree" type="text" value="<?php echo esc_attr( $univ_2_degree ); ?>"/>
</p>
<p>
<label for="rcp_univ_2_year"><?php _e( 'Year Graduated', 'rcp' ); ?></label>
<input name="rcp_univ_2_year" id="rcp_univ_2_year" type="text" value="<?php echo esc_attr( $univ_2_year ); ?>"/>
</p></div>
<div class="ed_fields">
<p>
<label for="rcp_univ_3"><?php _e( 'University', 'rcp' ); ?></label>
<input name="rcp_univ_3" id="rcp_univ_3" type="text" value="<?php echo esc_attr( $univ_3 ); ?>"/>
</p>
<p>
<label for="rcp_univ_3_major"><?php _e( 'Major', 'rcp' ); ?></label>
<input name="rcp_univ_3_major" id="rcp_univ_3_major" type="text" value="<?php echo esc_attr( $univ_3_major ); ?>"/>
</p>
<p>
<label for="rcp_univ_3_degree"><?php _e( 'Degree', 'rcp' ); ?></label>
<input name="rcp_univ_3_degree" id="rcp_univ_3_degree" type="text" value="<?php echo esc_attr( $univ_3_degree ); ?>"/>
</p>
<p>
<label for="rcp_univ_3_year"><?php _e( 'Year Graduated', 'rcp' ); ?></label>
<input name="rcp_univ_3_year" id="rcp_univ_3_year" type="text" value="<?php echo esc_attr( $univ_3_year ); ?>"/>
</p>
</div></div>
<?php
}
add_action( 'rcp_after_password_registration_field', 'pw_rcp_add_user_fields' );
add_action( 'rcp_profile_editor_after', 'pw_rcp_add_user_fields' );
/**
* Adds the custom fields to the member edit screen
*
*/
function pw_rcp_add_member_edit_fields( $user_id = 0 ) {
$address = get_user_meta( $user_id, 'rcp_address', true );
$city = get_user_meta( $user_id, 'rcp_city', true );
$state = get_user_meta( $user_id, 'rcp_state', true );
$zip = get_user_meta( $user_id, 'rcp_zip', true );
$phone = get_user_meta( $user_id, 'rcp_phone', true );
$company_organization = get_user_meta( $user_id, 'rcp_company_organization', true );
$title = get_user_meta( $user_id, 'rcp_title', true );
$spouse = get_user_meta( $user_id, 'rcp_spouse', true );
$year_joined = get_user_meta( $user_id, 'rcp_year_joined', true );
$other_membership = get_user_meta( $user_id, 'rcp_other_membership ', true );
$univ_1 = get_user_meta( $user_id, 'rcp_univ_1 ', true );
$univ_1_major = get_user_meta( $user_id, 'rcp_univ_1_major ', true );
$univ_1_degree = get_user_meta( $user_id, 'rcp_univ_1_degree ', true );
$univ_1_year = get_user_meta( $user_id, 'rcp_univ_1_year ', true );
$univ_2 = get_user_meta( $user_id, 'rcp_univ_2 ', true );
$univ_2_major = get_user_meta( $user_id, 'rcp_univ_2_major ', true );
$univ_2_degree = get_user_meta( $user_id, 'rcp_univ_2_degree ', true );
$univ_2_year = get_user_meta( $user_id, 'rcp_univ_2_year ', true );
$univ_3 = get_user_meta( $user_id, 'rcp_univ_3 ', true );
$univ_3_major = get_user_meta( $user_id, 'rcp_univ_3_major ', true );
$univ_3_degree = get_user_meta( $user_id, 'rcp_univ_3_degree ', true );
$univ_3_year = get_user_meta( $user_id, 'rcp_univ_3_year ', true );
?>
<tr valign="top">
<th scope="row" valign="top">
<label for="rcp_year_joined"><?php _e( 'Year the Member Originally Joined', 'rcp' ); ?></label>
</th>
<td>
<input name="rcp_year_joined" id="rcp_year_joined" type="text" value="<?php echo esc_attr( $year_joined ); ?>"/>
<p class="description"><?php _e( 'The year the member joined', 'rcp' ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" valign="top">
<label for="rcp_spouse"><?php _e( 'Spouse', 'rcp' ); ?></label>
</th>
<td>
<input name="rcp_spouse" id="rcp_spouse" type="text" value="<?php echo esc_attr( $spouse ); ?>"/>
<p class="description"><?php _e( 'The member\'s spouse or partner', 'rcp' ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" valign="top">
<label for="rcp_address"><?php _e( 'Street Address', 'rcp' ); ?></label>
</th>
<td>
<input name="rcp_address" id="rcp_address" type="text" value="<?php echo esc_attr( $address ); ?>"/>
<p class="description"><?php _e( 'The member\'s street address', 'rcp' ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" valign="top">
<label for="rcp_city"><?php _e( 'City', 'rcp' ); ?></label>
</th>
<td>
<input name="rcp_city" id="rcp_city" type="text" value="<?php echo esc_attr( $city ); ?>"/>
<p class="description"><?php _e( 'The member\'s city', 'rcp' ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" valign="top">
<label for="rcp_state"><?php _e( 'State', 'rcp' ); ?></label>
</th>
<td>
<input name="rcp_state" id="rcp_state" type="text" value="<?php echo esc_attr( $state ); ?>"/>
<p class="description"><?php _e( 'The member\'s state', 'rcp' ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" valign="top">
<label for="rcp_zip"><?php _e( 'Zip', 'rcp' ); ?></label>
</th>
<td>
<input name="rcp_zip" id="rcp_zip" type="text" value="<?php echo esc_attr( $zip ); ?>"/>
<p class="description"><?php _e( 'The member\'s zip code', 'rcp' ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" valign="top">
<label for="rcp_phone"><?php _e( 'Phone', 'rcp' ); ?></label>
</th>
<td>
<input name="rcp_phone" id="rcp_phone" type="text" value="<?php echo esc_attr( $phone ); ?>"/>
<p class="description"><?php _e( 'The member\'s phone number', 'rcp' ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" valign="top">
<label for="rcp_company_organization"><?php _e( 'Company or Organization', 'rcp' ); ?></label>
</th>
<td>
<input name="rcp_company_organization" id="rcp_company_organization" type="text" value="<?php echo esc_attr( $company_organization ); ?>"/>
<p class="description"><?php _e( 'The member\'s Company or Organization', 'rcp' ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" valign="top">
<label for="rcp_title"><?php _e( 'Title', 'rcp' ); ?></label>
</th>
<td>
<input name="rcp_title" id="rcp_title" type="text" value="<?php echo esc_attr( $title ); ?>"/>
<p class="description"><?php _e( 'The member\'s Title with Company or Organization', 'rcp' ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" valign="top">
<label for="rcp_other_membership"><?php _e( 'Other Memberships', 'rcp' ); ?></label>
</th>
<td>
<input name="rcp_other_membership" id="rcp_other_membership" type="text" value="<?php echo esc_attr( $other_membership ); ?>"/>
<p class="description"><?php _e( 'Other Memberships', 'rcp' ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" valign="top">
<label for="rcp_univ_1"><?php _e( 'University', 'rcp' ); ?></label>
</th>
<td>
<input name="rcp_univ_1" id="rcp_univ_1" type="text" value="<?php echo esc_attr( $univ_1 ); ?>"/>
<p class="description"><?php _e( 'University', 'rcp' ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" valign="top">
<label for="rcp_univ_1_major"><?php _e( 'Major', 'rcp' ); ?></label>
</th>
<td>
<input name="rcp_univ_1_major" id="rcp_univ_1_major" type="text" value="<?php echo esc_attr( $univ_1_major ); ?>"/>
<p class="description"><?php _e( 'Major', 'rcp' ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" valign="top">
<label for="rcp_univ_1_degree"><?php _e( 'Degree', 'rcp' ); ?></label>
</th>
<td>
<input name="rcp_univ_1_degree" id="rcp_univ_1_degree" type="text" value="<?php echo esc_attr( $univ_1_degree ); ?>"/>
<p class="description"><?php _e( 'Degree', 'rcp' ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" valign="top">
<label for="rcp_univ_1_year"><?php _e( 'Year', 'rcp' ); ?></label>
</th>
<td>
<input name="rcp_univ_1_year" id="rcp_univ_1_year" type="text" value="<?php echo esc_attr( $univ_1_year ); ?>"/>
<p class="description"><?php _e( 'Year', 'rcp' ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" valign="top">
<label for="rcp_univ_2"><?php _e( 'University', 'rcp' ); ?></label>
</th>
<td>
<input name="rcp_univ_2" id="rcp_univ_2" type="text" value="<?php echo esc_attr( $univ_2 ); ?>"/>
<p class="description"><?php _e( 'University', 'rcp' ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" valign="top">
<label for="rcp_univ_2_major"><?php _e( 'Major', 'rcp' ); ?></label>
</th>
<td>
<input name="rcp_univ_2_major" id="rcp_univ_2_major" type="text" value="<?php echo esc_attr( $univ_2_major ); ?>"/>
<p class="description"><?php _e( 'Major', 'rcp' ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" valign="top">
<label for="rcp_univ_2_degree"><?php _e( 'Degree', 'rcp' ); ?></label>
</th>
<td>
<input name="rcp_univ_2_degree" id="rcp_univ_2_degree" type="text" value="<?php echo esc_attr( $univ_2_degree ); ?>"/>
<p class="description"><?php _e( 'Degree', 'rcp' ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" valign="top">
<label for="rcp_univ_2_year"><?php _e( 'Year', 'rcp' ); ?></label>
</th>
<td>
<input name="rcp_univ_2_year" id="rcp_univ_2_year" type="text" value="<?php echo esc_attr( $univ_2_year ); ?>"/>
<p class="description"><?php _e( 'Year', 'rcp' ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" valign="top">
<label for="rcp_univ_3"><?php _e( 'University', 'rcp' ); ?></label>
</th>
<td>
<input name="rcp_univ_3" id="rcp_univ_3" type="text" value="<?php echo esc_attr( $univ_3 ); ?>"/>
<p class="description"><?php _e( 'University', 'rcp' ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" valign="top">
<label for="rcp_univ_3_major"><?php _e( 'Major', 'rcp' ); ?></label>
</th>
<td>
<input name="rcp_univ_3_major" id="rcp_univ_3_major" type="text" value="<?php echo esc_attr( $univ_3_major ); ?>"/>
<p class="description"><?php _e( 'Major', 'rcp' ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" valign="top">
<label for="rcp_univ_3_degree"><?php _e( 'Degree', 'rcp' ); ?></label>
</th>
<td>
<input name="rcp_univ_3_degree" id="rcp_univ_3_degree" type="text" value="<?php echo esc_attr( $univ_3_degree ); ?>"/>
<p class="description"><?php _e( 'Degree', 'rcp' ); ?></p>
</td>
</tr>
<tr valign="top">
<th scope="row" valign="top">
<label for="rcp_univ_3_year"><?php _e( 'Year', 'rcp' ); ?></label>
</th>
<td>
<input name="rcp_univ_3_year" id="rcp_univ_3_year" type="text" value="<?php echo esc_attr( $univ_3_year ); ?>"/>
<p class="description"><?php _e( 'Year', 'rcp' ); ?></p>
</td>
</tr>
<?php
}
add_action( 'rcp_edit_member_after', 'pw_rcp_add_member_edit_fields' );
/**
* Determines if there are problems with the registration data submitted
*
*/
function pw_rcp_validate_user_fields_on_register( $posted ) {
if( empty( $posted['rcp_address'] ) ) {
rcp_errors()->add( 'invalid_address', __( 'Please enter your street address', 'rcp' ), 'register' );
}
if( empty( $posted['rcp_city'] ) ) {
rcp_errors()->add( 'invalid_city', __( 'Please enter your city', 'rcp' ), 'register' );
}
if( empty( $posted['rcp_state'] ) ) {
rcp_errors()->add( 'invalid_state', __( 'Please enter your state', 'rcp' ), 'register' );
}
if( empty( $posted['rcp_zip'] ) ) {
rcp_errors()->add( 'invalid_zip', __( 'Please enter your zip', 'rcp' ), 'register' );
}
if( empty( $posted['rcp_phone'] ) ) {
rcp_errors()->add( 'invalid_phone', __( 'Please enter your phone number', 'rcp' ), 'register' );
}
}
add_action( 'rcp_form_errors', 'pw_rcp_validate_user_fields_on_register', 10 );
/**
* Stores the information submitted during registration
*
*/
function pw_rcp_save_user_fields_on_register( $posted, $user_id ) {
if( ! empty( $posted['rcp_address'] ) ) {
update_user_meta( $user_id, 'rcp_address', sanitize_text_field( $posted['rcp_address'] ) );
}
if( ! empty( $posted['rcp_city'] ) ) {
update_user_meta( $user_id, 'rcp_city', sanitize_text_field( $posted['rcp_city'] ) );
}
if( ! empty( $posted['rcp_state'] ) ) {
update_user_meta( $user_id, 'rcp_state', sanitize_text_field( $posted['rcp_state'] ) );
}
if( ! empty( $posted['rcp_zip'] ) ) {
update_user_meta( $user_id, 'rcp_zip', sanitize_text_field( $posted['rcp_zip'] ) );
}
if( ! empty( $posted['rcp_phone'] ) ) {
update_user_meta( $user_id, 'rcp_phone', sanitize_text_field( $posted['rcp_phone'] ) );
}
if( ! empty( $posted['rcp_company_organization'] ) ) {
update_user_meta( $user_id, 'rcp_company_organization', sanitize_text_field( $posted['rcp_company_organization'] ) );
}
if( ! empty( $posted['rcp_title'] ) ) {
update_user_meta( $user_id, 'rcp_title', sanitize_text_field( $posted['rcp_title'] ) );
}
if( ! empty( $posted['rcp_spouse'] ) ) {
update_user_meta( $user_id, 'rcp_spouse', sanitize_text_field( $posted['rcp_spouse'] ) );
}
if( ! empty( $posted['rcp_year_joined'] ) ) {
update_user_meta( $user_id, 'rcp_year_joined', sanitize_text_field( $posted['rcp_year_joined'] ) );
}
if( ! empty( $posted['rcp_other_membership'] ) ) {
update_user_meta( $user_id, 'rcp_other_membership', sanitize_text_field( $posted['rcp_other_membership'] ) );
}
if( ! empty( $posted['rcp_univ_1'] ) ) {
update_user_meta( $user_id, 'rcp_univ_1', sanitize_text_field( $posted['rcp_univ_1'] ) );
}
if( ! empty( $posted['rcp_univ_1_major'] ) ) {
update_user_meta( $user_id, 'rcp_univ_1_major', sanitize_text_field( $posted['rcp_univ_1_major'] ) );
}
if( ! empty( $posted['rcp_univ_1_degree'] ) ) {
update_user_meta( $user_id, 'rcp_univ_1_degree', sanitize_text_field( $posted['rcp_univ_1_degree'] ) );
}
if( ! empty( $posted['rcp_univ_1_year'] ) ) {
update_user_meta( $user_id, 'rcp_univ_1_year', sanitize_text_field( $posted['rcp_univ_1_year'] ) );
}
if( ! empty( $posted['rcp_univ_2'] ) ) {
update_user_meta( $user_id, 'rcp_univ_2', sanitize_text_field( $posted['rcp_univ_2'] ) );
}
if( ! empty( $posted['rcp_univ_2_major'] ) ) {
update_user_meta( $user_id, 'rcp_univ_2_major', sanitize_text_field( $posted['rcp_univ_2_major'] ) );
}
if( ! empty( $posted['rcp_univ_2_degree'] ) ) {
update_user_meta( $user_id, 'rcp_univ_2_degree', sanitize_text_field( $posted['rcp_univ_2_degree'] ) );
}
if( ! empty( $posted['rcp_univ_2_year'] ) ) {
update_user_meta( $user_id, 'rcp_univ_2_year', sanitize_text_field( $posted['rcp_univ_2_year'] ) );
}
if( ! empty( $posted['rcp_univ_3'] ) ) {
update_user_meta( $user_id, 'rcp_univ_3', sanitize_text_field( $posted['rcp_univ_3'] ) );
}
if( ! empty( $posted['rcp_univ_3_major'] ) ) {
update_user_meta( $user_id, 'rcp_univ_3_major', sanitize_text_field( $posted['rcp_univ_3_major'] ) );
}
if( ! empty( $posted['rcp_univ_3_degree'] ) ) {
update_user_meta( $user_id, 'rcp_univ_3_degree', sanitize_text_field( $posted['rcp_univ_3_degree'] ) );
}
if( ! empty( $posted['rcp_univ_3_year'] ) ) {
update_user_meta( $user_id, 'rcp_univ_3_year', sanitize_text_field( $posted['rcp_univ_3_year'] ) );
}
}
add_action( 'rcp_form_processing', 'pw_rcp_save_user_fields_on_register', 10, 2 );
/**
* Stores the information submitted profile update
*
*/
function pw_rcp_save_user_fields_on_profile_save( $user_id ) {
if( ! empty( $_POST['rcp_address'] ) ) {
update_user_meta( $user_id, 'rcp_address', sanitize_text_field( $_POST['rcp_address'] ) );
}
if( ! empty( $_POST['rcp_state'] ) ) {
update_user_meta( $user_id, 'rcp_state', sanitize_text_field( $_POST['rcp_state'] ) );
}
if( ! empty( $_POST['rcp_city'] ) ) {
update_user_meta( $user_id, 'rcp_city', sanitize_text_field( $_POST['rcp_city'] ) );
}
if( ! empty( $_POST['rcp_zip'] ) ) {
update_user_meta( $user_id, 'rcp_zip', sanitize_text_field( $_POST['rcp_zip'] ) );
}
if( ! empty( $_POST['rcp_phone'] ) ) {
update_user_meta( $user_id, 'rcp_phone', sanitize_text_field( $_POST['rcp_phone'] ) );
}
if( ! empty( $_POST['rcp_company_organization'] ) ) {
update_user_meta( $user_id, 'rcp_company_organization', sanitize_text_field( $_POST['rcp_company_organization'] ) );
}
if( ! empty( $_POST['rcp_title'] ) ) {
update_user_meta( $user_id, 'rcp_title', sanitize_text_field( $_POST['rcp_title'] ) );
}
if( ! empty( $_POST['rcp_spouse'] ) ) {
update_user_meta( $user_id, 'rcp_spouse', sanitize_text_field( $_POST['rcp_spouse'] ) );
}
if( ! empty( $_POST['rcp_year_joined'] ) ) {
update_user_meta( $user_id, 'rcp_year_joined', sanitize_text_field( $_POST['rcp_year_joined'] ) );
}
if( ! empty( $_POST['rcp_other_membership'] ) ) {
update_user_meta( $user_id, 'rcp_other_membership', sanitize_text_field( $_POST['rcp_other_membership'] ) );
}
if( ! empty( $_POST['rcp_univ_1'] ) ) {
update_user_meta( $user_id, 'rcp_univ_1', sanitize_text_field( $_POST['rcp_univ_1'] ) );
}
if( ! empty( $_POST['rcp_univ_1_major'] ) ) {
update_user_meta( $user_id, 'rcp_univ_1_major', sanitize_text_field( $_POST['rcp_univ_1_major'] ) );
}
if( ! empty( $_POST['rcp_univ_1_degree'] ) ) {
update_user_meta( $user_id, 'rcp_univ_1_degree', sanitize_text_field( $_POST['rcp_univ_1_degree'] ) );
}
if( ! empty( $_POST['rcp_univ_1_year'] ) ) {
update_user_meta( $user_id, 'rcp_univ_1_year', sanitize_text_field( $_POST['rcp_univ_1_year'] ) );
}
if( ! empty( $_POST['rcp_univ_2'] ) ) {
update_user_meta( $user_id, 'rcp_univ_2', sanitize_text_field( $_POST['rcp_univ_2'] ) );
}
if( ! empty( $_POST['rcp_univ_2_major'] ) ) {
update_user_meta( $user_id, 'rcp_univ_2_major', sanitize_text_field( $_POST['rcp_univ_2_major'] ) );
}
if( ! empty( $_POST['rcp_univ_2_degree'] ) ) {
update_user_meta( $user_id, 'rcp_univ_2_degree', sanitize_text_field( $_POST['rcp_univ_2_degree'] ) );
}
if( ! empty( $_POST['rcp_univ_2_year'] ) ) {
update_user_meta( $user_id, 'rcp_univ_2_year', sanitize_text_field( $_POST['rcp_univ_2_year'] ) );
}
if( ! empty( $_POST['rcp_univ_3'] ) ) {
update_user_meta( $user_id, 'rcp_univ_3', sanitize_text_field( $_POST['rcp_univ_3'] ) );
}
if( ! empty( $_POST['rcp_univ_3_major'] ) ) {
update_user_meta( $user_id, 'rcp_univ_3_major', sanitize_text_field( $_POST['rcp_univ_3_major'] ) );
}
if( ! empty( $_POST['rcp_univ_3_degree'] ) ) {
update_user_meta( $user_id, 'rcp_univ_3_degree', sanitize_text_field( $_POST['rcp_univ_3_degree'] ) );
}
if( ! empty( $_POST['rcp_univ_3_year'] ) ) {
update_user_meta( $user_id, 'rcp_univ_3_year', sanitize_text_field( $_POST['rcp_univ_3_year'] ) );
}
}
add_action( 'rcp_user_profile_updated', 'pw_rcp_save_user_fields_on_profile_save', 10 );
add_action( 'rcp_edit_member', 'pw_rcp_save_user_fields_on_profile_save', 10 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment