WordPress Send email notification when user role is changed
- Article
- Comment (2)
Hi, you are here to notify your users automatically, when you change their user role(here i considered you as the site owner or the admin of your WordPress CMS). So add the following function on your, WordPress, theme’s functions.php or your plugin’s main file. It will hook the function automatically.
function kv_user_role_change_mail( $user_id, $new_role ) { $site_url = get_bloginfo('wpurl'); $user_info = get_userdata( $user_id ); $to = $user_info->user_email; $subject = $site_url." Role has been changed "; $message = "Hi, " . $user_info->display_name .PHP_EOL. " Recently, your role has changed on ".$site_url.", congratulations you are now an " . $new_role."!".PHP_EOL. "Login and check your Privileges". PHP_EOL. wp_login_url(). "" ; wp_mail($to, $subject, $message); } add_action( 'set_user_role', 'kv_user_role_change_mail', 10, 2);
If you have any problem with it. comment below. I will help you.
How can I get the notification on site footer? Have any codex?
The article is about to send email notification to the user of wordpress. not site notifications