For a demo environment, I would like to pre-fill the username and password fields of the wp-login form with respectively “demo” and “demo” string.
Thus users will just need to click on the “Log-in” button to connect to the admin area.
There is a way to do that ? Maybe with a hook ?
Thanks for your advises
The Result
Username
You can declare the form field value global and prefill it.
Password
I found nothing that you can use to prefill it, so I’d add a note. Gladly/Sadly there’s the whole set of stylesheets for the admin UI available. So
.wrap
in connection withh2
gives a nice styling. The function is hooked to the additional fields hook for the admin hook. The priority is0
to set it above additional fields.Security: Hide Errors
As someone would get a visual proof that he entered an existing user name by default, I’d add the following to your functions.php file, to avoid telling if the username was guessed right:
Other filters
Notes:
login_enqueue_scripts
hook.login_headerurl
filter that filters the url. The linktitle
can be replaced usinglogin_headertitle
. Both trigger for multisite as well a single site setups.login_message
filter.you could use this code to auto login the user:
Here are 3 ways to do it:
The first way is to use the wp_signon hook
The second way, is to use jQuery
.val()
and add it to your login pageThe last way is to edit your
wp-login.php
file (Note, this is not recommended although it would work).