WooCommerce - excelling eCommerce
[resolved] password_reset hook missing argument 2 (6 posts)

  1. shmk
    Posted 1 year ago #

    I'm using woocommerce and I'm trying to attach a function to the password_reset hook:

    function my_password_reset($user, $new_password){
        /* actions */
    add_action('password_reset', 'my_password_reset');

    But it returns me that the second parameter, the plain password, is not passed to my function.

    Warning: Missing argument 2 for my_password_reset()

    I can't understand what is wrong with my function, anyone could help me?


  2. shmk
    Posted 1 year ago #

    I tried with WP 3.5.x and 3.6 with latest WooCommerce.

  3. Roy Ho
    Posted 1 year ago #

    Exactly what the error says...Your code should more like this:

    add_action( 'password_reset', 'my_password_reset', 10, 2 );
    function my_password_reset( $user, $new_password ) {
      // do stuff
  4. shmk
    Posted 1 year ago #

    Thanks, that solved the problem :)

    I took the code from the official codex:

    add_action( 'password_reset', 'my_password_reset' );
        function my_password_reset( $user, $new_pass ) {
            // Do something before password reset.

    But probably the codex is wrong ;)

  5. Roy Ho
    Posted 1 year ago #

    Yes the codex is outdated. I have now updated the codex.

  6. mppatil211
    Posted 1 year ago #

    @roy: I followed the same but still it is not working for me

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic