Make WordPress Core

Opened 7 years ago

Last modified 6 years ago

#38079 assigned enhancement

Add hooks before output for each action in wp-login.php

Reported by: jfarthing84's profile jfarthing84 Owned by: voldemortensen's profile voldemortensen
Milestone: Future Release Priority: normal
Severity: normal Version: 4.7
Component: Login and Registration Keywords: has-patch reporter-feedback
Focuses: Cc:

Description

7 years ago, in #9682, wp-login.php was made more pluggable. The thing is, if you just want to change the look (as my plugin "Theme My Login" does), you also have to replicate the logic.

Having an action that fires just before the login_header() call in each case of the action handler switch should be sufficient. One such hook is already present for one action: lost_password.

However, the hook register is already in use for the register link as is the format {$action}_form. So, I propose using pre_{$action}_form.

Patch incoming.

Attachments (2)

38079.patch (2.3 KB) - added by jfarthing84 7 years ago.
38079.2.patch (1.4 KB) - added by dingo_bastard 6 years ago.
Added action hooks inside login_header function

Download all attachments as: .zip

Change History (20)

@jfarthing84
7 years ago

#1 @jfarthing84
7 years ago

  • Keywords has-patch dev-feedback added
  • Summary changed from Add additional hooks for each handled action in wp-login.php to Add hooks before output for each action in wp-login.php

#2 @voldemortensen
6 years ago

  • Keywords commit added
  • Owner set to voldemortensen
  • Status changed from new to assigned

38079.patch looks good to me, the @since docs will need to be updated though.

#3 @voldemortensen
6 years ago

  • Milestone changed from Awaiting Review to 4.8

#4 @dingo_bastard
6 years ago

While I agree that this is cool thing to have, login_header function already has a lot of filters and action hooks that you can use to modify how the login form looks. So you can easily use login_header action for instance to place something before logo in the login form.
There is also login_messages filter that you can use to modify the login messages.

It would be better to place actions inside the login_header function, you could also filter them based on the error message.

Last edited 6 years ago by dingo_bastard (previous) (diff)

@dingo_bastard
6 years ago

Added action hooks inside login_header function

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


6 years ago

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


6 years ago

#7 @jbpaul17
6 years ago

  • Milestone changed from 4.8 to 4.8.1

Punting to 4.8.1 per today's bug scrub.

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


6 years ago

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


6 years ago

#10 @jbpaul17
6 years ago

  • Milestone changed from 4.8.1 to 4.9

Per today's bug scrub, we'll punt this as the focus for 4.8.1 is regressions only.

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


6 years ago

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


6 years ago

#13 @voldemortensen
6 years ago

  • Keywords dev-feedback removed

38079.patch still applies cleanly, @since docs just need to be updated.

#14 @SergeyBiryukov
6 years ago

  • Keywords reporter-feedback added; commit removed

I agree with @dingo_bastard that existing hooks in login_header() can be used to customize the login page, so I don't see how 38079.patch would make it more customizable.

38079.2.patch makes more sense to me, but I'd like know a use case for these new actions that cannot be achieved with existing hooks.

#15 @SergeyBiryukov
6 years ago

On second thought, hooks before any output might indeed be helpful for redirects or more extensive customizations.

Perhaps they need better names though. pre_lostpassword_form sounds like it fires after the header and right before the form, not before any output on the page.

If the goal is to short-circuit login_header(), maybe pre_login_header should be added instead.

#16 @SergeyBiryukov
6 years ago

  • Milestone changed from 4.9 to Future Release

#17 @SergeyBiryukov
6 years ago

There's a login_form_{$action} dynamic hook, so maybe pre_login_form_{$action}_header would be a better name for these new hooks from 38079.patch, which would expand to:

  • pre_login_form_lostpassword_header
  • pre_login_form_resetpass_header
  • pre_login_form_register_header
  • pre_login_form_login_header

#18 @dingo_bastard
6 years ago

The do_action hooks I added could be proven useful to add some additional messages (I think I was working for a client 6 months ago, and I could have benefitted from such hooks).

Note: See TracTickets for help on using tickets.