/** * Determines if an email is banned * * @since 2.0 * @return bool */ function give_is_email_banned($email = '') { if (empty($email)) { return false; } $ret = in_array(trim($email), give_get_banned_emails()); return apply_filters('give_is_email_banned', $ret, $email); }
/** * Check the purchase to ensure a banned email is not allowed through * * @since 1.0 * @return void */ function give_check_purchase_email($valid_data, $posted) { $is_banned = false; $banned = give_get_banned_emails(); if (empty($banned)) { return; } if (is_user_logged_in()) { // The user is logged in, check that their account email is not banned $user_data = get_userdata(get_current_user_id()); if (give_is_email_banned($user_data->user_email)) { $is_banned = true; } if (give_is_email_banned($posted['give_email'])) { $is_banned = true; } } elseif (isset($posted['give-purchase-var']) && $posted['give-purchase-var'] == 'needs-to-login') { // The user is logging in, check that their email is not banned $user_data = get_user_by('login', $posted['give_user_login']); if ($user_data && give_is_email_banned($user_data->user_email)) { $is_banned = true; } } else { // Guest purchase, check that the email is not banned if (give_is_email_banned($posted['give_email'])) { $is_banned = true; } } if ($is_banned) { // Set an error and give the donor a general error (don't alert them that they were banned) give_set_error('email_banned', __('An internal error has occurred, please try again or contact support.', 'give')); } }