WordPress.org

Support

Support » Plugins and Hacks » [Resolved] password_reset hook missing argument 2

[Resolved] password_reset hook missing argument 2

  • shmk
    Member

    @shmk

    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?

    http://wordpress.org/plugins/woocommerce/

Viewing 5 replies - 1 through 5 (of 5 total)
  • shmk
    Member

    @shmk

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

    Roy Ho
    Member

    @splashingpixelscom

    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
    }
    shmk
    Member

    @shmk

    Thanks, that solved the problem 🙂

    I took the code from the official codex:
    http://codex.wordpress.org/Plugin_API/Action_Reference/password_reset

    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 😉

    Roy Ho
    Member

    @splashingpixelscom

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

    mppatil211
    Member

    @mppatil211

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] password_reset hook missing argument 2’ is closed to new replies.