/** * Remove an email address to the customer from within the admin and log a customer note * and redirect back to the customer interface for feedback * * @since 2.6 * @return void */ function edd_remove_customer_email() { if (empty($_GET['id']) || !is_numeric($_GET['id'])) { return false; } if (empty($_GET['email']) || !is_email($_GET['email'])) { return false; } if (empty($_GET['_wpnonce'])) { return false; } $nonce = $_GET['_wpnonce']; if (!wp_verify_nonce($nonce, 'edd-remove-customer-email')) { wp_die(__('Nonce verification failed', 'easy-digital-downloads'), __('Error', 'easy-digital-downloads'), array('response' => 403)); } $customer = new EDD_Customer($_GET['id']); if ($customer->remove_email($_GET['email'])) { $url = add_query_arg('edd-message', 'email-removed', admin_url('edit.php?post_type=download&page=edd-customers&view=overview&id=' . $customer->id)); $user = wp_get_current_user(); $user_login = !empty($user->user_login) ? $user->user_login : '******'; $customer_note = __(sprintf('Email address %s removed by %s', $_GET['email'], $user_login), 'easy-digital-downloads'); $customer->add_note($customer_note); } else { $url = add_query_arg('edd-message', 'email-remove-failed', admin_url('edit.php?post_type=download&page=edd-customers&view=overview&id=' . $customer->id)); } wp_safe_redirect($url); exit; }
/** * Process the 'remove' URL on the profile editor when customers wish to remove an email address * * @since 2.6 * @return void */ function edd_process_profile_editor_remove_email() { if (!is_user_logged_in()) { return false; } // Pending users can't edit their profile if (edd_user_pending_verification()) { return false; } // Nonce security if (!wp_verify_nonce($_GET['_wpnonce'], 'edd-remove-customer-email')) { return false; } if (empty($_GET['email']) || !is_email($_GET['email'])) { return false; } $customer = new EDD_Customer(get_current_user_id(), true); if ($customer->remove_email($_GET['email'])) { $url = add_query_arg('updated', true, $_GET['redirect']); $user = wp_get_current_user(); $user_login = !empty($user->user_login) ? $user->user_login : '******'; $customer_note = __(sprintf('Email address %s removed by %s', $_GET['email'], $user_login), 'easy-digital-downloads'); $customer->add_note($customer_note); } else { edd_set_error('profile-remove-email-failure', __('Error removing email address from profile. Please try again later.', 'easy-digital-downloads')); $url = $_GET['redirect']; } wp_safe_redirect($url); exit; }