1

is any way to add custom class name to input field in login from in wp_login_form function?

<input type="text" name="log" id="' . esc_attr( $args['id_username'] ) . '" class="input" value="' . esc_attr( $args['value_username'] ) . '" size="20" tabindex="10" />

1 Answer 1

3

While there is no direct filter available to modify the output of username input field. You can do this by enqueuing a js on login page and then adding a css class to username input field. Please see if below helps:

add_action( 'login_head', 'add_login_css' );
function add_login_css(){
    wp_register_script(
        'extra-login-css', 
        get_stylesheet_directory_uri() . '/js/extra-login-css.js',
        array( 'jquery' ),
        '',
        TRUE
    );
    wp_enqueue_script( 'extra-login-css' );
}

Make sure the path for extra-login-css.js mentioned above is correct or else you can update it as per your directory structure. Add the following code in that js file.

( function( $ ) {

   $("#user_login").addClass("my-login-username");

} )( jQuery );
1

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.