Theme My Login (TML)
-
Hi
I want to add additional field to the registration field.
I have therefore added the following to the register-form.php
<p>
<label for=”first_name<?php $template->the_instance(); ?>”><?php _e( ‘First name’, ‘theme-my-login’ ) ?></label>
<input type=”text” name=”first_name” id=”first_name<?php $template->the_instance(); ?>” class=”input” value=”<?php $template->the_posted_value( ‘first_name’ ); ?>” size=”20″ tabindex=”20″ />
</p>
<p>
<label for=”last_name<?php $template->the_instance(); ?>”><?php _e( ‘Last name’, ‘theme-my-login’ ) ?></label>
<input type=”text” name=”last_name” id=”last_name<?php $template->the_instance(); ?>” class=”input” value=”<?php $template->the_posted_value( ‘last_name’ ); ?>” size=”20″ tabindex=”20″ />
</p>
<p>
<label for=”phone<?php $template->the_instance(); ?>”><?php _e( ‘phone’, ‘theme-my-login’ ) ?></label>
<input type=”text” name=”phone” id=”phone<?php $template->the_instance(); ?>” class=”input” value=”<?php $template->the_posted_value( ‘phone’ ); ?>” size=”20″ tabindex=”20″ />
</p>In addition I have added following to function.php
//* Start Extra user fields
function tml_edit_user_profile( $profileuser ) {
?>
<p>
<label for=”phone”>Phone Number</label>
<input id=”phone” type=”text” name=”phone” value=”<?php echo $profileuser->phone; ?>” />
</p>
<?php
}add_action( ‘edit_user_profile’, ‘tml_edit_user_profile’ );
//* END extra user fields
//* Start Customize TML registration
function tml_registration_errors( $errors ) {
if ( empty( $_POST[‘first_name’] ) )
$errors->add( ’empty_first_name’, ‘ERROR: Please enter your first name.’ );
if ( empty( $_POST[‘last_name’] ) )
$errors->add( ’empty_last_name’, ‘ERROR: Please enter your last name.’ );
if ( empty( $_POST[‘phone’] ) )
$errors->add( ’empty_phone’, ‘ERROR: Please enter your phone number.’ );
return $errors;
}
add_filter( ‘registration_errors’, ‘tml_registration_errors’ );function tml_user_register( $user_id ) {
if ( !empty( $_POST[‘first_name’] ) )
update_user_meta( $user_id, ‘first_name’, $_POST[‘first_name’] );
if ( !empty( $_POST[‘last_name’] ) )
update_user_meta( $user_id, ‘last_name’, $_POST[‘last_name’] );
if ( !empty( $_POST[‘phone’] ) )
update_user_meta( $user_id, ‘phone’, $_POST[‘phone’] );
}
add_action( ‘user_register’, ‘tml_user_register’ );//* END Customize TML registration
So far this all works and when I log in to the backend I can see the additional fields.
However the “phone” field is a new field not existing by standard in WordPress.And this is now causing following problem. The phone field is shown in the admin section for the registered user. However the phone field can not be updated and it is also not shown when the user want to update his profile through the front end.
Any help appreciated
The topic ‘Theme My Login (TML)’ is closed to new replies.