Ready to get started?Download WordPress


Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Action Reference/login form


The 'login_form' action hook is used to customize the built-in WordPress login form.

Use in conjunction with 'login_head' (for validation).


This example demonstrates how to add a new field to the login form. Keep in mind that this won't be saved automatically. You will still need to set up validation rules and manually handle saving of the additional form fields.


function myplugin_add_login_fields() {

    //Get and set any values already sent
    $user_extra = ( isset( $_POST['user_extra'] ) ) ? $_POST['user_extra'] : '';

        <label for="user_extra"><?php _e('Extra Field','mydomain') ?><br />
            <input type="text" name="user_extra" id="user_extra" class="input" value="<?php echo esc_attr(stripslashes($user_extra)); ?>" size="25" /></label>


As said above, for validation, use 'login_head'.


The below example shows how to translate the login form, page, fields or labels:

function my_translatorr2()
  $your_content= preg_replace('/\<label for="user_login"\>(.*?)\<br/',        'Usernumia: ',$content);
  $your_content= preg_replace('/\<label for="user_pass"\>(.*?)\<br/',        'Passwiert:',$content);

  echo $our_content;
add_action( 'login_form', 'my_translatorr2' );

p.s. Choose the codes/blocks for translation accurately, otherwise the above function may change other parts of the login page, so, be advised.


Simple example to add a note or bit of text below the password box:


function login_extra_note() {

    //Adding the text
    <p>You can type a little note to those logging in here.</p>