Add open student registration with email confirmation and approval
CI / Tests (PHP 8.1) (pull_request) Successful in 1m18s
CI / Tests (PHP 8.2) (pull_request) Successful in 1m18s
CI / No Debug Code (pull_request) Successful in 2s
CI / PHPStan (pull_request) Successful in 3m20s
CI / Coding Standards (pull_request) Successful in 3m25s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m33s
CI / Build Plugin Zip (pull_request) Skipped
CI / Tests (PHP 8.1) (pull_request) Successful in 1m18s
CI / Tests (PHP 8.2) (pull_request) Successful in 1m18s
CI / No Debug Code (pull_request) Successful in 2s
CI / PHPStan (pull_request) Successful in 3m20s
CI / Coding Standards (pull_request) Successful in 3m25s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m33s
CI / Build Plugin Zip (pull_request) Skipped
Students could previously join by invite only. Add an optional self-approval mode, toggled from Studio Settings → Registration: anyone may sign up on the existing [us_student_register] page, confirm their email via a tokenised link, and then be approved by a studio admin before the account is usable. - Enabling the toggle mirrors WordPress's own membership settings (users_can_register + default_role = us_student) and snapshots their previous values so disabling restores them. - WordPress's native registration form is blocked while open registration is on (login_init redirect + registration_errors fail-safe + register_url) so it cannot bypass signup policy acceptance. - Pending accounts: unconfirmed email cannot log in; confirmed but unapproved can log in but the booking capability is withheld and the booking page shows an "awaiting approval" screen. - Approve/reject from Students → Pending Students; reject hard-deletes the account so the email is freed to re-apply. - Invite registration is unchanged; both modes coexist. Account lifecycle lives in user meta (RegistrationStatus); no new tables. Closes #63 Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
if (! defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
use Unsupervised\Schedular\Auth\RegistrationApprovalController;
|
||||
|
||||
/**
|
||||
* @var array<int, \WP_User> $awaitingApproval Confirmed, awaiting a decision.
|
||||
* @var array<int, \WP_User> $awaitingConfirmation Not yet confirmed their email.
|
||||
*/
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h1><?php esc_html_e('Pending Students', 'unsupervised-schedular'); ?></h1>
|
||||
|
||||
<div class="notice notice-info inline">
|
||||
<p>
|
||||
<?php esc_html_e('Students who signed themselves up appear here. Once they confirm their email you can approve them into a full student account, or reject the application to remove it.', 'unsupervised-schedular'); ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<h2><?php esc_html_e('Awaiting approval', 'unsupervised-schedular'); ?></h2>
|
||||
<?php if (empty($awaitingApproval)) : ?>
|
||||
<p><?php esc_html_e('No students are awaiting approval.', 'unsupervised-schedular'); ?></p>
|
||||
<?php else : ?>
|
||||
<table class="widefat striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php esc_html_e('Name', 'unsupervised-schedular'); ?></th>
|
||||
<th><?php esc_html_e('Email', 'unsupervised-schedular'); ?></th>
|
||||
<th><?php esc_html_e('Registered', 'unsupervised-schedular'); ?></th>
|
||||
<th><?php esc_html_e('Actions', 'unsupervised-schedular'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($awaitingApproval as $user) : ?>
|
||||
<tr>
|
||||
<td><?php echo esc_html((string) $user->display_name); ?></td>
|
||||
<td><?php echo esc_html((string) $user->user_email); ?></td>
|
||||
<td><?php echo esc_html((string) $user->user_registered); ?></td>
|
||||
<td>
|
||||
<form method="post" style="display:inline">
|
||||
<?php wp_nonce_field(RegistrationApprovalController::NONCE_ACTION); ?>
|
||||
<input type="hidden" name="user_id" value="<?php echo esc_attr((string) $user->ID); ?>">
|
||||
<button type="submit" name="usc_action" value="approve" class="button button-primary"><?php esc_html_e('Approve', 'unsupervised-schedular'); ?></button>
|
||||
</form>
|
||||
<form method="post" style="display:inline" onsubmit="return confirm('<?php echo esc_js(__('Reject and delete this application?', 'unsupervised-schedular')); ?>');">
|
||||
<?php wp_nonce_field(RegistrationApprovalController::NONCE_ACTION); ?>
|
||||
<input type="hidden" name="user_id" value="<?php echo esc_attr((string) $user->ID); ?>">
|
||||
<button type="submit" name="usc_action" value="reject" class="button button-link-delete"><?php esc_html_e('Reject', 'unsupervised-schedular'); ?></button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
|
||||
<h2><?php esc_html_e('Awaiting email confirmation', 'unsupervised-schedular'); ?></h2>
|
||||
<?php if (empty($awaitingConfirmation)) : ?>
|
||||
<p><?php esc_html_e('No students are awaiting email confirmation.', 'unsupervised-schedular'); ?></p>
|
||||
<?php else : ?>
|
||||
<table class="widefat striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php esc_html_e('Name', 'unsupervised-schedular'); ?></th>
|
||||
<th><?php esc_html_e('Email', 'unsupervised-schedular'); ?></th>
|
||||
<th><?php esc_html_e('Registered', 'unsupervised-schedular'); ?></th>
|
||||
<th><?php esc_html_e('Actions', 'unsupervised-schedular'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($awaitingConfirmation as $user) : ?>
|
||||
<tr>
|
||||
<td><?php echo esc_html((string) $user->display_name); ?></td>
|
||||
<td><?php echo esc_html((string) $user->user_email); ?></td>
|
||||
<td><?php echo esc_html((string) $user->user_registered); ?></td>
|
||||
<td>
|
||||
<form method="post" style="display:inline" onsubmit="return confirm('<?php echo esc_js(__('Reject and delete this application?', 'unsupervised-schedular')); ?>');">
|
||||
<?php wp_nonce_field(RegistrationApprovalController::NONCE_ACTION); ?>
|
||||
<input type="hidden" name="user_id" value="<?php echo esc_attr((string) $user->ID); ?>">
|
||||
<button type="submit" name="usc_action" value="reject" class="button button-link-delete"><?php esc_html_e('Reject', 'unsupervised-schedular'); ?></button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
Reference in New Issue
Block a user