Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save nextab/32c3afa7abc4528e2fdacb1796ca7376 to your computer and use it in GitHub Desktop.

Select an option

Save nextab/32c3afa7abc4528e2fdacb1796ca7376 to your computer and use it in GitHub Desktop.
#region Check if user e-mail is unique
function jet_fb_v_check_user_email($value, $context): bool {
if (!is_user_logged_in()) {
return !in_array($value, get_all_user_emails());
}
return get_user_data() === $value;
}
#endregion Check if user e-mail is unique
#region Get all user e-mails and return them as an array
function get_all_user_emails() {
$emails = array(); // Initialize an empty array to hold the email addresses
// Query to get all user data
$users = get_users();
// Loop through each user to fetch their email
foreach ($users as $user) {
$emails[] = $user->user_email;
}
return $emails; // Return the array of email addresses
}
#endregion Get all user e-mails and return them as an array

ghost commented Nov 2, 2023

Copy link
Copy Markdown

Warum nicht einfach email_exists() oder username_exists()? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment