I need to write code before user can enter username and password. So, I have code written just after the following line in wp-login.php page:
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login';
The above line is somewhere # 372.
My line:
if ($action == 'login') {
// My code
}
When done like this, script run before even username and pwd box comes. I am thinking of adding hook etc so that I do not need to modify wp-login.php page.
Any idea?
If you don’t care about the actual action you can use
login_init
action like this:But if you want to handle only special actions, then you need to hook into
login_form_{action}
action, like this:Or like this:
If you need to add some CSS or JS to your login page, then you need to use
login_enqueue_scripts
action: