hey shane i found a document for this over on my theme site , i did a little work on it and have now got this in my functions.php
this adds a simple name field to registration form , stores to the database displays on the profile , can be edited etc etc , so it works perfect, i need to replace the simple name box to my toolset custom user field(address) . which is user-address.
reg for as it stands is here
hidden link
custom field for user-address is here (this field already shows in the edit profile page funnily enough so its really only needs adding on the front end reg form and storing to database on registration)
hidden link (same user and pass as previously supplied , if needed please set me a privte reply)
the code in my functions is
/******* martin/userfields ************/
// display the custom fields
function at_custom_fields() {
?>
<fieldset class="at_fieldset">
<legend><?php _e('trainer adress', 'appthemes'); ?></legend>
<p>
<label for="at_name"><?php _e('adress', 'appthemes'); ?></label><br/>
<input class="text" type="text" name="at_name" id="at_name" value=<?php if (isset($_POST['at_name'])) echo esc_attr($_POST['at_name']); ?>>
</p>
</fieldset>
<style type="text/css">
.at_fieldset { border: 1px solid #ccc; padding: 10px; border-radius: 5px; }
.at_referral_note { font-size: 12px; color: #ccc; }
.at_number { width: 100px }
</style>
<?php
}
// display the custom fields on registration form
add_action( 'register_form', 'at_custom_fields' );
// register the extra fields as user metadata
function at_register_custom_fields( $user_id, $password = "", $meta = array() ) {
// custom fields
$fields = array(
'at_name',
);
// cleans and updates the custom fields
foreach ( $fields as $field ) {
$value = stripslashes( trim( $_POST[$field] ) ) ;
if ( ! empty( $value ) ) {
update_user_meta( $user_id, $field, $value );
}
}
}
// save the custom fields to the database as soon as the user is registered on the database
add_action( 'user_register', 'at_register_custom_fields' );
// display custom fields/values on the backend or frontend
function at_custom_fields_display( $user ) {
$user_id = $user->ID;
?>
<?php if ( is_admin() ) { ?>
<!-- // show the backend HTML -->
<h3><?php _e('Additional Information', 'appthemes'); ?></h3>
<table class="form-table">
<tr>
<th><label for="at_name"><?php _e('adress', 'appthemes'); ?></label></th>
<td>
<input class="text" type="text" name="at_name" id="at_name" value="<?php echo get_user_meta( $user_id, 'at_name', true ) ; ?>">
</td>
</tr>
</table>
<?php } else { ?>
<!-- // show the frontend HTML -->
<fieldset>
<legend><?php _e('trainer adress', 'appthemes'); ?></legend>
<p>
<label for="at_name"><?php _e('address', 'appthemes'); ?></label>
<input class="text" type="text" name="at_name" id="at_name" value="<?php echo get_user_meta( $user_id, 'at_name', true ) ; ?>">
</p>
</fieldset>
<?php } ?>
<?php
}
// display the custom fields on the user profile page (frontend and admin)
add_action( 'show_user_profile', 'at_custom_fields_display' ); // frontend
add_action( 'edit_user_profile', 'at_custom_fields_display' ); // backend
// updates custom fields
function at_custom_fields_update( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) )
return false;
// updatable fields
$fields = array(
'at_name',
);
foreach ( $fields as $field ) {
$value = stripslashes( trim( $_POST[$field] ) ) ;
if ( ! empty( $value ) ) {
update_user_meta( $user_id, $field, $value );
}
}
}
// additional fields update
add_action( 'edit_user_profile_update', 'at_custom_fields_update' );
add_action( 'personal_options_update', 'at_custom_fields_update' );
many many thanks