Reputation: 3897
A standard log-in page (specifically, the default WordPress wp-login.php page).
Here are two live examples:
I need to disable the auto-focusing of the first textbox in the form.
None of the approaches work.
Upvotes: 1
Views: 1536
Reputation: 365
For those coming from Google, there is now a hook for this in the core (correct from V5.2, could be earlier!).
wp-login.php:1149 enable_login_autofocus : Boolean
add_filter('enable_login_autofocus', '__return_false');
Will disable the autofocus javascript snippet
Upvotes: 2
Reputation: 5193
I've posted a few solutions on the WordPress SE here. Basically there are two ways around it (in WordPress 4.0) that don't involve changing the code itself. Kill the function altogether using a dirty hack:
add_action("login_form", "kill_wp_attempt_focus");
function kill_wp_attempt_focus() {
global $error;
$error = TRUE;
}
Or use Geeklab's solution to modify the HTML code through buffering, allowing you to specifically kill the autofocus. Good luck!
Upvotes: 1
Reputation: 3897
I've found a solution based on charlietfl's setTimeout function.
setTimeout(function() {
$( '<input type="text" id="focusfix" style="position:absolute; top:-1000px;"/>' ).insertBefore( "#loginform #user_login" );
$('#loginform #focusfix').focus();
$('#loginform #focusfix').select();
}, 205);
Upvotes: 0