Forgot to add the key, not that it matters though, doesn’t seem to do anything but just in case here is the modified code to be put in the same place.
global $screen;
$screen = get_current_screen();
$options = get_option( 'csds_userRegAide_Options' );
if( !empty( $screen ) ){
if( $screen->id == 'user' ){
$user = new WP_User( $user_id );
$user_email = $user->user_email;
$newuser_key = substr( md5( $user_id ), 0, 5 );
$caps = get_user_meta( $user->ID, 'wp_capabilities', true );
$roles = array_keys( ( array )$caps );
add_option( 'new_user_' . $newuser_key, array( 'user_id' => $user_id, 'email' => $user->user_email, 'role' => $roles[0] ) );
$message = __( 'Hi,
You\'ve been invited to join \'%1$s\' at
%2$s with the role of %3$s.
Please click the following link to confirm the invite:
%4$s' );
wp_mail( $user_email, sprintf( __( '[%s] Joining confirmation' ), wp_specialchars_decode( get_option( 'blogname' ) ) ), sprintf( $message, get_option( 'blogname' ), home_url(), wp_specialchars_decode( translate_user_role( $roles[0] ) ), home_url( "/newbloguser/$newuser_key/" ) ) );
$redirect = add_query_arg( array('update' => 'add'), 'user-new.php' );
}
}