Support » Plugins and Hacks » Theme My Login » [Resolved] [Plugin: Theme My Login] Additional fields in register-form.php

[Resolved] [Plugin: Theme My Login] Additional fields in register-form.php

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Jeff Farthing


    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_errors to require fields and tml_new_user_registered to 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?

    Plugin Author Jeff Farthing


    Create /wp-content/plugins/theme-my-login-custom.php and 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.php file as well.

    Don’t quote me on this, but I think Jeff is saying that you will have to enter new registration_errors and new tml_new_user_registered variables to the theme-my-login-custom.php file for each additional item you wish to add to your register-form.php file. 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

    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><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” />
    <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″ />

    and also I Create /wp-content/plugins/theme-my-login-custom.php and add some code to it.


    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

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] [Plugin: Theme My Login] Additional fields in register-form.php’ is closed to new replies.