I would like to override the default WordPress Login page: wp-login.php.

The reason is that, I want to write some custom code at the top of the file, that checks some conditions in the backend, and performs stuff like redirecting the user to some other page.

I would like to do this because I want to perform my own authentication logic in a custom file, without showing the default WordPress login form. My logic includes parsing of some cookie and session data (no login form in particular, may be a custom form).

I actually thought of writing my logic in the header.php file of a child theme, but unfortunately the wp-login.php file does not include the theme's header file.

I don't want to edit the wp-login.php directly as I'am worried all my modifications will be lost with any future WordPress update.

Is there a way I can safely override the WordPress login page without incurring any loss after any WordPress update?

Or is it possible to route all requests to wp-login.php, to a custom PHP file, so that I can write all my logic in that file?

  • 2
    Please explain why you want to do that. Maybe it's a XY Problem.
    – kaiser
    Mar 5, 2014 at 12:50

1 Answer 1


Don't modify core, use the actions and hooks system instead

add_action( 'login_init', 'yourloginoverrides' );

function yourloginoverrides() {
    // do some check and call wp_redirect if its true or whatever you wanted to do
  • Is there a way, i can display some custom file, instead of wp-login.php (so that i can write my own code there) ? Mar 5, 2014 at 12:37
  • 1
    hmmm so your question is actually multiple questions? Well you'll want to implement your own login handler, then use the answer to this question to redirect there, which isn't the same thing, you should write a separate question for how to handle logins in a custom script now that you know how to redirect to it.
    – Tom J Nowell
    Mar 5, 2014 at 12:48
  • @shasi There's nothing that you can't do during login_init as Tom has shown you.
    – kaiser
    Mar 5, 2014 at 12:49
  • That includes swapping out the WordPress logo and CSS, and adding more hooks to add additional markup/css/js
    – Tom J Nowell
    Mar 5, 2014 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.