I want a description under the user name input field in the Wordpress registration form like in the next example. How can I do this?

//create an extra field in login page for invitation code
add_action( 'register_form', 'add_invitation_code_field' );

function add_invitation_code_field() {
         <label for="invitation_code">
            Invitation code
            <input id="invitation_code" class="input" type="text" size="20" value="" name="invitation_code"/>
            <span class="description"><?php _e("Description text"); ?></span>

OK, that's possible using JavaScript (jQuery lib). Code -

// load jquery on login screen if not loaded already
add_action( 'login_enqueue_scripts', 'wpse_login_head' );
function wpse_login_head(){

add_action( 'register_form', 'wpse_register_form' );
function wpse_register_form(){ ?>

    <!-- we have used an unique id for the description tag -->
    <span id="user_login_description" style=" display:none;" class="description"><?php _e("Description text"); ?></span>

    <!-- the following line of code move the description after the username input -->
    <script type="text/javascript">jQuery('#user_login_description').appendTo('#registerform p:nth-child(1) label').show();</script>
  • After changing the function add_invitation_code_field(){ ?> to function awpse_register_form(){ ?> this works like a charm. Thank you! – Iurie Malai Feb 17 '14 at 18:56
  • In the same context, is there a way to change the style of the user name input field? I am trying to change the margin: 2px 6px 16px 0px; to margin: 2px 6px 6px 0px; but without succes :((. – Iurie Malai Feb 17 '14 at 19:34
  • 1
    Well this should be easy though. You can add CSS for #user_login selector, and use login_enqueue_scripts hook. I have written an article about how to customize WordPress login screen which have and example of login page CSS implementation. – Shazzad Feb 17 '14 at 20:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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