# Placeholders in Login Form Fields

> Adds hint text inside the username, password and email fields on the login, lost password and registration screens.

- Type: PHP
- Runs: Run everywhere
- Category: [Login](https://wpide.com/library/category/login/)
- Tags: login, form, ux
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/login-field-placeholders/

## Code

```php
// Field ID => placeholder.
$wpide_login_placeholders = array(
    'user_login' => 'you@example.com',
    'user_pass'  => 'Your password',
    'user_email' => 'you@example.com',
);

add_action( 'login_footer', function () use ( $wpide_login_placeholders ) {
    ?>
    <script>
    ( function ( map ) {
        Object.keys( map ).forEach( function ( id ) {
            var field = document.getElementById( id );
            if ( field && ! field.getAttribute( 'placeholder' ) ) {
                field.setAttribute( 'placeholder', map[ id ] );
            }
        } );
    } )( <?php echo wp_json_encode( $wpide_login_placeholders ); ?> );
    </script>
    <?php
} );
```

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Placeholders in Login Form Fields" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
