2

For increase security i'm looking for a way to run a custom function when an Admin user change it's password in Wordpress CMS.

please help me. thank you.

Nadeem_MK
  • 7,533
  • 7
  • 50
  • 61
Ehsan
  • 2,273
  • 8
  • 36
  • 70

1 Answers1

3

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;
    }
    elseif(!$_POST['pass1'] === $_POST['pass2']){
        return;
    }


    // password changed...
}
add_action( 'profile_update', 'my_profile_update' );
Gopal S Rathore
  • 9,885
  • 3
  • 30
  • 38
  • `profile_update` hook works with all users profile update, If you want to apply function for only admin users then check the capability with `current_user_can()` – jogesh_pi Apr 15 '15 at 05:33