I know how to add a custom field to WP register form via register_form hook. But this adds the new field at the end of the form. How would I go about moving this field at the beginning of the form?


function mytheme_register_form() 
    $first_name = ( ! empty( $_POST['first_name'] ) ) ? trim( $_POST['first_name'] ) : '';

        <label for="first_name"><?php _e( 'Your name', 'mytheme' ) ?><br />
            <input type="text" name="first_name" id="first_name" class="input" value="<?php echo esc_attr( wp_unslash( $first_name ) ); ?>" size="25" />
add_action( 'register_form', 'mytheme_register_form' );


2 Answers 2


You can't, because of wp-login.php structure. Here is code with register_form hook:

<form name="registerform" id="registerform" action="<?php echo esc_url( site_url( 'wp-login.php?action=register', 'login_post' ) ); ?>" method="post" novalidate="novalidate">
        <label for="user_login"><?php _e('Username') ?><br />
        <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr(wp_unslash($user_login)); ?>" size="20" /></label>
        <label for="user_email"><?php _e('Email') ?><br />
        <input type="email" name="user_email" id="user_email" class="input" value="<?php echo esc_attr( wp_unslash( $user_email ) ); ?>" size="25" /></label>
     * Fires following the 'Email' field in the user registration form.
     * @since 2.1.0
    do_action( 'register_form' );
    <p id="reg_passmail"><?php _e( 'Registration confirmation will be emailed to you.' ); ?></p>
    <br class="clear" />
    <input type="hidden" name="redirect_to" value="<?php echo esc_attr( $redirect_to ); ?>" />
    <p class="submit"><input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Register'); ?>" /></p>
  • Damn, I see. So the only option is a whole custom form ... thanks.
    – trainoasis
    Commented Aug 9, 2016 at 8:58

I just figured out a way to accomplish this.

On the register_form page, there is a second example (after the example you've given) which is about changing the register form using output buffering. The example actually has some typos and won't work, but we can use the idea.

The following code should work:

function my_register_form() {

   $content = ob_get_contents();
   $my_content = '<label for="first_name">First name<br />
                    <input type="text" name="first_name" id="first_name" class="input" value="" size="25" />
                    <label for="user_login">';
   $content = str_replace ( '<label for="user_login">', $my_content, $content );

   echo $content;
add_action( 'register_form', 'my_register_form' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.