WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. shmk
    Member
    Posted 10 months 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?

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

  2. shmk
    Member
    Posted 10 months ago #

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

  3. Roy Ho
    Member
    Posted 10 months 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
    Member
    Posted 10 months ago #

    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 ;)

  5. Roy Ho
    Member
    Posted 10 months ago #

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

  6. mppatil211
    Member
    Posted 4 months ago #

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

Reply

You must log in to post.

About this Plugin

About this Topic