What are the potential security risks of allowing all users to view the guest list on a website, and how can these risks be mitigated?

Potential security risks of allowing all users to view the guest list on a website include exposing personal information of guests, such as names and contact details, which can lead to privacy violations and potential misuse of this information. To mitigate these risks, access to the guest list should be restricted to authorized users only, such as event organizers or registered guests.

// Check if user is authorized to view the guest list
if($user->isEventOrganizer() || $user->isRegisteredGuest()) {
    // Display guest list
    echo "Guest list: John Doe, Jane Smith, etc.";
} else {
    // Redirect unauthorized users to homepage
    header("Location: index.php");
    exit();
}