I have managed to to the registration form to save the field entries to the wp usermeta and the profile page to pull the values of the various fields from the user database.
I now have an issue with updating the various field values to the WP_usermeta.... I have looked at so many forum post on all sorts of websites and have yet to find an answer that works...
Could someone please help, this is rather urgent, below is my code that retrieves and populates the profile form.... I just need to get it too save any updates made to the form including if the password is updated.
I cannot provide a url as I am working locally using mamp.
add_action( 'show_user_profile', 'show_extra_profile_fields' );
add_action( 'edit_user_profile', 'show_extra_profile_fields' );
//show_extra_profile_fields add extra meta fields to user profile on the back end of WP in the meta
function show_extra_profile_fields( $user ) { ?>
<h3>Extra profile information</h3>
<table class="form-table">
<tr>
<th><label for="title">Title</label></th>
<td>
<input type="text" name="title" id="title" value="<?php echo esc_attr( get_the_author_meta( 'Title', $user->ID ) ); ?>" class="regular-text" />
</td>
</tr>
<tr>
<th><label for="gender">Gender</label></th>
<td>
<input type="text" name="gender" id="gender" value="<?php echo esc_attr( get_the_author_meta( 'Gender', $user->ID ) ); ?>" class="regular-text" />
</td>
</tr>
<tr>
<th><label for="dob">DOB</label></th>
<td>
<input type="text" name="dob" id="dob" value="<?php echo esc_attr( get_the_author_meta( 'DOB', $user->ID ) ); ?>" class="regular-text" />
</td>
</tr>
<tr>
<th><label for="mobile">Mobile</label></th>
<td>
<input type="text" name="mobile" id="Mobile" value="<?php echo esc_attr( get_the_author_meta( 'Mobile', $user->ID ) ); ?>" class="regular-text" />
</td>
</tr>
<tr>
<th><label for="Address">Address</label></th>
<td>
<input type="text" name="strt" id="strt" value="<?php echo esc_attr( get_the_author_meta( 'Address-street', $user->ID ) ); ?>" class="regular-text" />
<span>Address 1</span>
<input type="text" name="addy2" id="addy2" value="<?php echo esc_attr( get_the_author_meta( 'Address-2', $user->ID ) ); ?>" class="regular-text" />
<span>Address 2</span>
<input type="text" name="city" id="city" value="<?php echo esc_attr( get_the_author_meta( 'Address-city', $user->ID ) ); ?>" class="regular-text" />
<span>city</span>
<input type="text" name="province" id="province" value="<?php echo esc_attr( get_the_author_meta( 'Address-province', $user->ID ) ); ?>" class="regular-text" />
<span>State/ Province</span>
<input type="text" name="zip" id="zip" value="<?php echo esc_attr( get_the_author_meta( 'Address-zip', $user->ID ) ); ?>" class="regular-text" />
<span>Postal / Zip code</span>
<input type="text" name="country" id="country" value="<?php echo esc_attr( get_the_author_meta( 'Address-country', $user->ID ) ); ?>" class="regular-text" />
<span>Country</span>
<input type="text" name="opt" id="opt" value="<?php echo esc_attr( get_the_author_meta( 'OPT', $user->ID ) ); ?>" class="regular-text" />
<span>OPT</span>
</td>
</tr>
</table>
<?php }
/*
*
* Populate the form field specifically on the form My Profile (form 3)
* return RGForms::get_form( 3, false, false, false, $field_values, false, 1);
*
*/
function user_profile_shortcode( $atts, $content ){
global $current_user;
get_currentuserinfo();
//UNTESTED
$meta = get_user_meta( $current_user->id );
$field_values = array(
'email' => $current_user->user_email,
'first_name' => $meta['first_name'][0],
'last_name' => $meta['last_name'][0],
'Title' => $meta['Title'][0],
'Mobile' => $meta['Mobile'][0],
'DOB' => $meta['DOB'][0],
'Gender' => $meta['Gender'][0],
'Address-2' => $meta['Address-2'][0],
'Address-street' => $meta['Address-street'][0],
'Address-city' => $meta['Address-city'][0],
'Address-zip' => $meta['Address-zip'][0],
'Address-province' => $meta['Address-province'][0],
'Address-country' => $meta['Address-country'][0],
'OPT' => $meta['OPT'][0]
);
return RGForms::get_form( 3, false, false, false, $field_values, false, 1);
}
//[user_profile] Will Display The Form.
add_shortcode( 'user_profile', 'user_profile_shortcode' );