# Turn Off Autofocus on the Login Form

> Stops the login, lost password and registration screens from putting the cursor in the first field as soon as they load, so the page does not jump or pop up the on-screen keyboard.

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

## Code

```php
// The main login form has a filter for this.
add_filter( 'enable_login_autofocus', '__return_false' );

// The lost password, registration and reset password forms focus their first field without a filter,
// so take the focus away again right after WordPress sets it.
add_action( 'login_footer', function () {
    wp_print_inline_script_tag( '(function(){var field=document.activeElement;if(field&&field!==document.body&&field.form){field.blur();}})();' );
} );
```

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Turn Off Autofocus on the Login Form" 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/
