[Plugin: Theme My Login] Additional fields in register-form.php
-
Hello,
I’d like to add some text-fields in the registration form:
firstname
lastname
website…so the ‘official’ fields from wordpress. In my case it should be set obgligatory during the registration process.
Thx!
Sebastian
-
Copy register-form.php into your current theme’s directory and edit it as you see fit.
Please note that simply adding the fields will not save the data. You will need to use provided hooks to achieve your desired results.
You will want to use
registration_errorsto require fields andtml_new_user_registeredto save the data.You will need to use provided hooks to achieve your desired results.
Could you specify it? I’m not quite familiar in this stuff :/ So if I would add a new input for the available ‘user_company’ like
<input style="width:300px;height:34px;line-height:27px;border:1px solid #ececec;outline:none;padding-left:5px;color:#585858;float:left; background:url(/images/search_bg.png);" type="text" name="user_company" id="user_company<?php $template->the_instance(); ?>" class="input" value="<?php $template->the_posted_value( 'user_company' ); ?>" size="20" />…it would safe the infos?
Create
/wp-content/plugins/theme-my-login-custom.phpand add this code to it.After that, you will be able to access the property via the WP_User object:
$user->user_company.This sounds really really great, thank you for this! And If I’d like to offer the fields user_company and e.g. user_telephone… BUT only make the user_company obligatory, I only need to add the user_company to the registration_errors-function?
I don’t believe so…I’m following this as I’m looking to make some changes to the
register-form.phpfile as well.Don’t quote me on this, but I think Jeff is saying that you will have to enter new
registration_errorsand newtml_new_user_registeredvariables to thetheme-my-login-custom.phpfile for each additional item you wish to add to yourregister-form.phpfile. Jeff’s example only shows how to add a line for Companies (user_company, empty_company).Hello Kyle, thx for your reply! This sounds complicated, a bit too complicated, so I guess I should avoid adding additional and obligatory registration-fields. Hopefully, Jeff will include this option (custom-fields) as an future feature one day. Thx for you work and fast support! Sebastian
hello
I add some extra fields ` <p>
<label for=”first_name”><?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( ‘user_first_name’ ); ?>” size=”20″ maxlength=”255″ alt=”First Name” />
</p>
<p><label for=”last_name”><?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( ‘user_last_name’ ); ?>” size=”20″ maxlength=”255″ alt=”Last Name” />
</p>
<p>
<label for=”user_phone<?php $template->the_instance(); ?>”><?php _e( ‘Phone’, ‘theme-my-login’ ) ?></label>
<input type=”text” name=”user_phone” id=”user_phone<?php $template->the_instance(); ?>” class=”input” value=”<?php $template->the_posted_value( ‘user_phone’ ); ?>” size=”20″ />
</p>and also I Create /wp-content/plugins/theme-my-login-custom.php and add some code to it.<?php
function registration_errors( $errors ) {
if ( empty( $_POST[‘user_phone’] ) )
$errors->add( ’empty_phone’, ‘<strong>ERROR</strong>: Please enter your phone number.’ );
return $errors;
}
add_action( ‘registration_errors’, ‘registration_errors’ );function tml_new_user_registered( $user_id ) {
update_user_meta( $user_id, ‘user_phone’, $_POST[‘user_phone’] );
}
add_action( ‘tml_new_user_registered’, ‘tml_new_user_registered’ );?>`
and still didn’t get the field working for store data in profile form and error when left my phone empty
and thanks for this plugin
The topic ‘[Plugin: Theme My Login] Additional fields in register-form.php’ is closed to new replies.