function user_role_update( $user_id, $new_role ) {
if ($new_role == 'editor') {
$site_url = get_bloginfo('wpurl');
$user_info = get_userdata( $user_id );
$to = $user_info->user_email;
$subject = "Congrats your Role changed to ".$new_role."";
$message = "Hello " .$user_info->display_name . ", your role has changed on ".$site_url.", congratulations you are now an " . $new_role;
$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);