Title: Fatal error when using action hook lostpassword_post
Last modified: November 14, 2023

---

# Fatal error when using action hook lostpassword_post

 *  Resolved [David Marín Carreño](https://wordpress.org/support/users/davefx/)
 * (@davefx)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/fatal-error-when-using-action-hook-lostpassword_post/)
 * Hi!
 * One of my sites has experienced a fatal error in wp-2fa/includes/classes/Authenticator/
   class-reset-passord.php, line 46 .
 * Could you please add default values for both parameters, so no fatal error is
   generated when the action hook lostpassword_post is called with only one parameter,
   or even without parameters?
 * Thanks a lot!

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Contributor [robertabela](https://wordpress.org/support/users/robert681/)
 * (@robert681)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/fatal-error-when-using-action-hook-lostpassword_post/#post-17199484)
 * Hello David,
 * Thank you for using our plugin. I am sorry to read about your issue.
 * Can you please tell us a bit more about your setup, and how your website is setup(
   which plugins are being used / causing this etc) so there is one parameter or
   are no parameters when the action hook is called?
 * We’d like to better understand your setup and also reproduce the issue from our
   end so we can create a fix. We avoid adding “blind fixes” because such fixes 
   could be affecting other areas of the plugin.
 * Looking forward to hearing from you.
 *  Thread Starter [David Marín Carreño](https://wordpress.org/support/users/davefx/)
 * (@davefx)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/fatal-error-when-using-action-hook-lostpassword_post/#post-17200259)
 * Basically, we have a custom plugin that makes use of this hook without providing
   a second argument (without $user_data), this way:
 *     ```wp-block-code
       do_action( 'lostpassword_post', $errors );
       ```
   
 * This doesn’t cause any problem without WP-2FA (as all the functions in WordPress
   called by this hook receive one argument), but if WP-2FA is active, this call
   generates a fatal error due to the missing parameter.
 * We just propose you to simply change the line 46 of class-reset-passord.php from:
 *     ```wp-block-code
       public static function lostpassword_post( $errors, $user_data ) {
       ```
   
 * to:
 *     ```wp-block-code
       public static function lostpassword_post( $errors, $user_data = false ) {
       ```
   
 *  Plugin Contributor [robertabela](https://wordpress.org/support/users/robert681/)
 * (@robert681)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/fatal-error-when-using-action-hook-lostpassword_post/#post-17204609)
 * Hello David,
 * Thank you for the explanation. We’ve looked into this and discussed it with the
   team; as of v5.4 a second parameter was added to this action ([https://developer.wordpress.org/reference/hooks/lostpassword_post/](https://developer.wordpress.org/reference/hooks/lostpassword_post/)).
   This parameter increases the security of the whole process, hence as as security
   plugin we expect that to be present.
 * I understand that WordPress core accepts a single parameter, but that is because
   of backward compatibility and to make up for old plugins which might have not
   been updated yet.
 * So considering this is a custom plugin, and this is a security improvement our
   recommendation is to update the custom plugin rather than allow “less secure”
   practise via our plugin.
 * I hope the above clarifies the issue. Should you have any other questions, please
   do not hesitate to ask.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Fatal error when using action hook lostpassword_post’ is closed to new
replies.

 * ![](https://ps.w.org/wp-2fa/assets/icon-256x256.png?rev=2961533)
 * [WP 2FA - Two-factor authentication for WordPress](https://wordpress.org/plugins/wp-2fa/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-2fa/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-2fa/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-2fa/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-2fa/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-2fa/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [robertabela](https://wordpress.org/support/users/robert681/)
 * Last activity: [2 years, 6 months ago](https://wordpress.org/support/topic/fatal-error-when-using-action-hook-lostpassword_post/#post-17204609)
 * Status: resolved