2

I've enqueued a style for my WordPress login page like so:

function login_stylesheet() {
    wp_enqueue_style( 'custom-login', plugins_url( 'style-login.css', __FILE__ ) );
}
add_action( 'login_enqueue_scripts', 'login_stylesheet' );

However, this doesn't enqueue the script for the password reset page.

Does anyone know how to customize the password reset page?

Update just to clarify -

The style sheet loads on the wp-login.php page:

http://dev.yazminmedia.com/tresstank/wp-login.php

On the "Lost Your Password" page, it does not load:

http://dev.yazminmedia.com/wp-login.php?action=lostpassword

  • 1
    What does »doesn't enqueue« mean? Is there completely no reference to a custom resource, or is the URL to the resource wrong, so that the request ends in 404? – David Feb 7 '16 at 9:49
  • There is no reference at all on the Lost Your Password page. The page loads, but it has no custom styling. I added links to my original question above to clarify. – Yazmin Feb 8 '16 at 2:51
  • Where do you call the code above? When I register a listener to login_enqueue_script it gets called independent of the action URL parameter. (WP 4.4.2, listener registered directly in functions.php and a plugin main file.) – David Feb 8 '16 at 11:58
2

Your code works fine just the way you have it - I tried it. Maybe you have another plugin that unhooks existing login_enqueue_scripts hooks disabling yours?

Otherwise it works provided:

  • The code is in a plugin;
  • style-login.css file is in the same directory as the plugin;
  • Some WP CSS uses !important; such as body{ background }. So, you'll need !important for your CSS properties to override WP.

UPDATE 02/07/16:

Your updated information makes a really big difference!

The code will only work as desired on a WP single site install, not multisite. You have a multisite install using subfolders.

Notice the links in your updated question:

http://dev.yazminmedia.com/tresstank/wp-login.php

http://dev.yazminmedia.com/wp-login.php?action=lostpassword

The password reset link points to your main site not the tresstank subsite.

It's not a plugin conflict issue, it's a WP redirect issue.

Try this link: http://yazmin.bkstest.com/wp-login.php then click on "Lost your password?". It will not redirect to the main site and the login style will still be applied because I use the code that can be found here https://gist.github.com/eteubert/293e07a49f56f300ddbb to change the default WP behavior. It's a must have for multisites. It solves issues with links in the password reset emails pointing the user to the main site (where they can't login) instead of the subsite they are a member of.

If you add the code from the above gist to your plugin your problem will most likely be solved. It works great on subdomain setups but I haven't tested it with subfolder installs.

NOTE: The code from the gist should be placed in a network activated plugin.

  • Thank you. I thought the same, but wouldn't a plugin interfering with the enqueueing of my custom style sheet (which is loaded via plugin) affect the login page and the "lost your password" page equally? I added links to my original question above so you can see it is functioning as intended via the information I got from the WP Codex, but it does not seem to affect the password reset page, which is the problem. – Yazmin Feb 8 '16 at 2:53
  • @yazmin - the links you included tell a whole new story. I have update my answer. – BillK Feb 8 '16 at 4:44
  • You, sir, are a God-send. I can't believe the URL difference wasn't registering. That plugin fixed my issue. Thank you! – Yazmin Feb 9 '16 at 0:32

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.