Preview:
// Notify user when role is changed

function notify_user_on_role_change( $user_id, $new_role ) {

    $user_info = get_userdata( $user_id );

    $to = $user_info->user_email;

    $subject = 'Your role has been changed';

    $message = 'Hello ' . $user_info->display_name . ', your role has been changed to ' . $new_role . '.';

    wp_mail( $to, $subject, $message );

}

add_action( 'set_user_role', 'notify_user_on_role_change', 10, 2 );
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter