Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I would like to track when a user changes their password. Is there a way to detect when a password has been changed?

share|improve this question
    
WordPress already does this. You'll get an email when the password is changed. –  chrisguitarguy May 7 '12 at 3:15
    
I have never received an email when another user changed their password. –  Chad Snow May 7 '12 at 4:30
add comment

1 Answer

up vote 3 down vote accepted

WordPress sends an email to the admin's email when a user resets their password.

To get a notification when a user changes their password you could hook into the profile_update action which is fired when a user's profile is updated.

When the action is fired WordPress has already validated and updated the user's details we only need to check if the user submitted a password with the request, if it was submitted then the user's password has changed.

function my_profile_update( $user_id ) {
    if ( ! isset( $_POST['pass1'] ) || '' == $_POST['pass1'] ) {
        return;
    }

    // password changed...
}
add_action( 'profile_update', 'my_profile_update' );
share|improve this answer
    
Shouldn't the if statement be like this: if ( ! isset( $_POST['pass1'] ) || '' != $_POST['pass1'] ) { –  gmaggio May 18 '13 at 7:46
    
@gmaggio , no because the first if verifies if the password is changed and if the password isn't null. Both must be false. if the second is '' != $_POST['pass1'] any password, not empty will return TRUE –  Eek Sep 13 '13 at 13:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.