Created
February 7, 2013 16:10
-
-
Save INDIAN2020/4731974 to your computer and use it in GitHub Desktop.
user role change email
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
/* | |
Send email notification when user role changes | |
Adding this snippet to the functions.php of your wordpress theme will send the member an email notification when the user’s role has changed. | |
*/ | |
function user_role_update( $user_id, $new_role ) { | |
$site_url = get_bloginfo('wpurl'); | |
$user_info = get_userdata( $user_id ); | |
$to = $user_info->user_email; | |
$subject = "Role changed: ".$site_url.""; | |
$message = "Hello " .$user_info->display_name . " your role has changed on ".$site_url.", congratulations you are now an " . $new_role; | |
wp_mail($to, $subject, $message); | |
} | |
add_action( 'set_user_role', 'user_role_update', 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment