I wanted to make a few changes to the WordPress login page (wp-login.php) but keep all existing functionality. I didn’t want to mess around with any core WP files. Sounds like it should be easy…unfortunately not.
Here’s how you can make a copy of the existing wp-login.php, put it in your own theme, and make it useable so you can then go on to modify it however you like.
- copy wp-login.php to your theme directory, call it whatever you like
- replace the following lines:
3 * WordPress User Page
5 * Handles authentication, registering, resetting passwords, forgot password,
6 * and other user handling.
8 * @package WordPress
11 /** Make sure that the WordPress bootstrap has run before continuing. */
12 require( dirname(__FILE__) . ‘/wp-load.php’ );
3 Template Name: Your Custom Login/Registration Page
- If you’re using the vim editor, use the following two lines:
Otherwise, use whatever find and replace function your editor has to replace $_REQUEST[‘action’] with $_REQUEST[‘do’], and ?action with ?do
- Create a page on your site, select the new template, and note down the page ID and slug
- Back to the custom login file, do the following in vim (where 591 is your page ID, and ‘login-register’ is your page slug):
Or if not using vim, replace wp_login_url() with get_permalink(<your page ID>), replace wp-login.php with <your page slug>, and wp_lost_password_url() with get_permalink(<your page ID>).?do=lostpassword
That should be it. If you now go to that page it should show you the normal WP login form, and the links for registering and lost passwords should also go to your custom page. The lost password feature will also direct the user back to the custom page to reset their password.
You can now edit the page however you like!
NB: point 3 may seem a bit unenecessary; we’re changing the ?action= to ?do=, however, wierdly, if you leave as-is and post new user registration data to http://yoursite.com/customlogin?action=register, WP calls the register_post action (which registers new users) before it even loads your custom template, and then it calls it again during your template. Very bizarre, but changing it works fine.