Created
November 13, 2020 09:08
-
-
Save webdados/b8a2a039d8418f9ac26a804250d49bb4 to your computer and use it in GitHub Desktop.
Email to admin when WordPress lost password is requested
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Email to admin when WordPress lost password is requested */ | |
add_action( 'lostpassword_post', 'my_lostpassword_post', 10, 2 ); | |
function my_lostpassword_post( $errors, $user_data ) { | |
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { | |
//check ip from share internet | |
$ip = $_SERVER['HTTP_CLIENT_IP']; | |
} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { | |
//to check ip is pass from proxy | |
$ip = $_SERVER['HTTP_X_FORWARDED_FOR']; | |
} else { | |
$ip = $_SERVER['REMOTE_ADDR']; | |
} | |
wp_mail( | |
get_option( 'admin_email' ), | |
'Someone tried to retrieve the password for '.$_POST['user_login'].' - '.date_i18n( 'Y-m-d H:i:s)' ), | |
'IP: '.$ip | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment