i have written a small piece of code so when a user forgets and resets the password it will be emailed to the user

currently i have added that code directly to the wp-login.php page

do_action( 'validate_password_reset', $errors, $user );

if ( ( ! $errors->get_error_code() ) && isset( $_POST['pass1'] ) && !empty( $_POST['pass1'] ) ) {
            reset_password($user, $_POST['pass1']);
    setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );

///my code

login_header( __( 'Password Reset' ), '<p class="message reset-pass">' . __( 'Your password has been reset.' ) . ' <a href="' . esc_url( wp_login_url() ) . '">' . __( 'Log in' ) . '</a></p>' );

the problem im having is modifying the core is not a good idea.. so instead of modifying the core i need to add it as a plugin..

i went through the https://codex.wordpress.org/Writing_a_Plugin page but im still not clear about it coz im new to wordpress plugins thing.

Can someone please guide me on how this can be done?

  • Did you find a solution on this?
    – jdm2112
    Sep 3, 2015 at 20:57
  • @jdm2112 nt yet.. im trying to work on a solution based on your answer... im new to this wordpress plugin thing.. trying to grasp it :)
    – LiveEn
    Sep 4, 2015 at 6:32

1 Answer 1


You need to hook into that action, not repeat it. I believe you want something like this. The function will fire with the validate_password_reset

add_action( 'validate_password_reset', 'my_passwd_function', 10, 2 );

function my_passwd_function() {

    echo 'Your Code Here';


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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