feat: unify invite flow with referral ref
This commit is contained in:
1 parent
f1d6809109
commit
b501cf4611
47 files changed
+1083
-2548
No files matched your search
@@ -102,6 +102,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['user_login'], $_POST[
|
||||
if (class_exists('\AKSRT\Auth\Service')) {
|
||||
$result = \AKSRT\Auth\Service::register_user($_POST, ['oauth_bind_data' => null, 'obk' => '']);
|
||||
if (!empty($result['success'])) {
|
||||
$ref_notice = trim((string) ($result['notice'] ?? ''));
|
||||
if (!empty($result['verification_required'])) {
|
||||
$register_success = sprintf(
|
||||
'%s <a href="%s">%s</a>',
|
||||
@@ -115,19 +116,20 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['user_login'], $_POST[
|
||||
esc_url(aksrt_get_login_url())
|
||||
);
|
||||
}
|
||||
if ($ref_notice !== '') {
|
||||
$register_success .= ' ' . esc_html($ref_notice);
|
||||
}
|
||||
} else {
|
||||
$register_error = $result['error'] ?? __('注册失败', 'aksrt');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$invite_prefill = '';
|
||||
if (!empty($_GET['ref'])) {
|
||||
$invite_prefill = sanitize_key(wp_unslash($_GET['ref']));
|
||||
} elseif (!empty($_GET['invite'])) {
|
||||
$invite_prefill = sanitize_key(wp_unslash($_GET['invite']));
|
||||
} elseif (!empty($_COOKIE['aksrt_invite'])) {
|
||||
$invite_prefill = sanitize_key(wp_unslash($_COOKIE['aksrt_invite']));
|
||||
$ref_prefill = '';
|
||||
if (!empty($_COOKIE['aksrt_referral'])) {
|
||||
$ref_prefill = sanitize_key(wp_unslash($_COOKIE['aksrt_referral']));
|
||||
} elseif (!empty($_GET['ref'])) {
|
||||
$ref_prefill = sanitize_key(wp_unslash($_GET['ref']));
|
||||
}
|
||||
|
||||
$agreement = function_exists('aksrt_get_auth_agreement_view')
|
||||
@@ -246,18 +248,18 @@ $sign_css_ver = file_exists(get_template_directory() . '/assets/css/routes/sign.
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
$invite_cfg = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_invite_registration_config() : null;
|
||||
if ($invite_cfg && ($invite_cfg['register_field'] ?? 'hidden') !== 'hidden') {
|
||||
$mode = (string) $invite_cfg['register_field'];
|
||||
$invit_hint = $mode === 'required'
|
||||
? (string) ($invite_cfg['must_desc'] ?? '')
|
||||
: (string) ($invite_cfg['open_desc'] ?? '');
|
||||
$ref_cfg = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_referral_registration_settings() : null;
|
||||
if ($ref_cfg && !empty($ref_cfg['enabled']) && ($ref_cfg['register_field'] ?? 'hidden') !== 'hidden') {
|
||||
$mode = (string) $ref_cfg['register_field'];
|
||||
$ref_hint = $mode === 'required'
|
||||
? (string) ($ref_cfg['required_desc'] ?? '')
|
||||
: (string) ($ref_cfg['open_desc'] ?? '');
|
||||
?>
|
||||
<div class="form-field">
|
||||
<label for="sign-invite"><?php esc_html_e('邀请码', 'aksrt'); ?><?php echo $mode === 'optional' ? ' <small style="color:var(--muted-color);">(' . esc_html__('选填', 'aksrt') . ')</small>' : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></label>
|
||||
<div class="input-wrap"><input type="text" name="invite_code" id="sign-invite" maxlength="32" autocomplete="off" value="<?php echo esc_attr($invite_prefill); ?>" <?php echo $mode === 'required' ? 'required' : ''; ?>></div>
|
||||
<?php if ($invit_hint !== '') : ?>
|
||||
<p class="sign-hint"><?php echo wp_kses_post($invit_hint); ?></p>
|
||||
<label for="sign-ref"><?php esc_html_e('推广码', 'aksrt'); ?><?php echo $mode === 'optional' ? ' <small style="color:var(--muted-color);">(' . esc_html__('选填', 'aksrt') . ')</small>' : ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></label>
|
||||
<div class="input-wrap"><input type="text" name="ref" id="sign-ref" maxlength="12" autocomplete="off" value="<?php echo esc_attr($ref_prefill); ?>" <?php echo $mode === 'required' ? 'required' : ''; ?>></div>
|
||||
<?php if ($ref_hint !== '') : ?>
|
||||
<p class="sign-hint"><?php echo wp_kses_post($ref_hint); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
@@ -19,9 +19,9 @@ if (class_exists('\AKSRT\Auth\OAuth')) {
|
||||
$registration_open = true;
|
||||
$email_verification = false;
|
||||
$close_signin = false;
|
||||
$invite_field_mode = 'hidden';
|
||||
$invite_field_hint = '';
|
||||
$invite_prefill = '';
|
||||
$ref_field_mode = 'hidden';
|
||||
$ref_field_hint = '';
|
||||
$ref_prefill = '';
|
||||
$show_qrcode_tab = false;
|
||||
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
@@ -32,19 +32,17 @@ if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
$email_verification = \AKSRT\Settings\Settings::registration_requires_email_verification();
|
||||
$close_signin = \AKSRT\Settings\Settings::close_signin();
|
||||
|
||||
$invite_cfg = \AKSRT\Settings\Settings::get_invite_registration_config();
|
||||
$invite_field_mode = (string) ($invite_cfg['register_field'] ?? 'hidden');
|
||||
$invite_field_hint = $invite_field_mode === 'required'
|
||||
? (string) ($invite_cfg['must_desc'] ?? '')
|
||||
: (string) ($invite_cfg['open_desc'] ?? '');
|
||||
$ref_cfg = \AKSRT\Settings\Settings::get_referral_registration_settings();
|
||||
$ref_field_mode = !empty($ref_cfg['enabled']) ? (string) ($ref_cfg['register_field'] ?? 'hidden') : 'hidden';
|
||||
$ref_field_hint = $ref_field_mode === 'required'
|
||||
? (string) ($ref_cfg['required_desc'] ?? '')
|
||||
: (string) ($ref_cfg['open_desc'] ?? '');
|
||||
}
|
||||
|
||||
if (!empty($_GET['ref'])) {
|
||||
$invite_prefill = sanitize_key(wp_unslash($_GET['ref']));
|
||||
} elseif (!empty($_GET['invite'])) {
|
||||
$invite_prefill = sanitize_key(wp_unslash($_GET['invite']));
|
||||
} elseif (!empty($_COOKIE['aksrt_invite'])) {
|
||||
$invite_prefill = sanitize_key(wp_unslash($_COOKIE['aksrt_invite']));
|
||||
if (!empty($_COOKIE['aksrt_referral'])) {
|
||||
$ref_prefill = sanitize_key(wp_unslash($_COOKIE['aksrt_referral']));
|
||||
} elseif (!empty($_GET['ref'])) {
|
||||
$ref_prefill = sanitize_key(wp_unslash($_GET['ref']));
|
||||
}
|
||||
|
||||
foreach ($oauth_providers as $provider) {
|
||||
@@ -171,17 +169,17 @@ $logo_url = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings:
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($invite_field_mode !== 'hidden') : ?>
|
||||
<?php if ($ref_field_mode !== 'hidden') : ?>
|
||||
<div class="aksrt-modal-auth__field">
|
||||
<label for="modal-reg-invite">
|
||||
<?php esc_html_e('邀请码', 'aksrt'); ?>
|
||||
<?php if ($invite_field_mode === 'optional') : ?>
|
||||
<label for="modal-reg-ref">
|
||||
<?php esc_html_e('推广码', 'aksrt'); ?>
|
||||
<?php if ($ref_field_mode === 'optional') : ?>
|
||||
<small><?php esc_html_e('(选填)', 'aksrt'); ?></small>
|
||||
<?php endif; ?>
|
||||
</label>
|
||||
<input type="text" id="modal-reg-invite" name="invite_code" value="<?php echo esc_attr($invite_prefill); ?>" <?php echo $invite_field_mode === 'required' ? 'required' : ''; ?> placeholder="<?php esc_attr_e('请输入邀请码', 'aksrt'); ?>">
|
||||
<?php if ($invite_field_hint !== '') : ?>
|
||||
<p class="aksrt-modal-auth__hint"><?php echo wp_kses_post($invite_field_hint); ?></p>
|
||||
<input type="text" id="modal-reg-ref" name="ref" maxlength="12" value="<?php echo esc_attr($ref_prefill); ?>" <?php echo $ref_field_mode === 'required' ? 'required' : ''; ?> placeholder="<?php esc_attr_e('请输入推广码', 'aksrt'); ?>">
|
||||
<?php if ($ref_field_hint !== '') : ?>
|
||||
<p class="aksrt-modal-auth__hint"><?php echo wp_kses_post($ref_field_hint); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
Reference in new issue
Block a user