Give this code a try:
var query = window.location.search.substring(1);
var paramList = query.split('&');
for (var i=0; i < paramList.length; i++)
{
var param = paramList[i].split('=');
if(param[0] == 'email')
{
var element = document.getElementById('user_login');
if (element)
{
element.value = decodeURIComponent(param[1]);
}
}
}
I used the browser inspector console to test it out quickly and debug it — there was an error in the syntax (a missing parenthesis) and user_email
needed to be user_login
. It’s a great tool if you aren’t familiar with it and can speed up the time it takes to write JS. Also, element.value
was the key to changing the field.
Incidentally, you don’t need this line:
add_action('login_enqueue_scripts', 'is_wplogin');
… in fact, it doesn’t do anything! prefillercheck
calls is_wplogin
directly.