Placeholders in Login Form Fields
Adds hint text inside the username, password and email fields on the login, lost password and registration screens.
Opens WPIDE on
Code
// Field ID => placeholder.
$wpide_login_placeholders = array(
'user_login' => '[email protected]',
'user_pass' => 'Your password',
'user_email' => '[email protected]',
);
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 add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.