Sending an email notification to the administrator when changing data in profiles.
Receiving notifications about a user profile change is useful in two cases. In the first case you always know, which of your users is active and what data has changed, and in the second case you will know, if the password was changed before the site was hacked, which will make it more likely for you to understand through which account the site was hacked and change the password in it to a more strict one.
1 2 3 4 5 6 7 8 9 |
function user_profile_update( $user_id ) { $site_url = get_bloginfo('wpurl'); $user_info = get_userdata( $user_id ); $to = $user_info->user_email; $subject = "Profile Updated: ".$site_url.""; $message = "Hello " .$user_info->display_name . "\nYour profile has been updated!\n\nThank you for visiting\n ".$site_url.""; wp_mail( $to, $subject, $message); } add_action( 'profile_update', 'user_profile_update', 10, 2); |
Code snippet checked, everything works perfectly. The letter is sent to the administrator.
/*
- Basic web design course;
- Site layout;
- General course on CMS WordPress and continuation of the course on template development;
- Website development in PHP.