在网站注册后,我想显示一个隐藏的div div在同一页。 但注册后,页面将加载并显示相同的页面。显示div后的进程注册,woocommerce
这里的形式,handler.php
public static function process_registration() {
$nonce_value = isset($_POST['_wpnonce']) ? $_POST['_wpnonce'] : '';
$nonce_value = isset($_POST['woocommerce-register-nonce']) ? $_POST['woocommerce-register-nonce'] : $nonce_value;
if (! empty($_POST['register']) && wp_verify_nonce($nonce_value, 'woocommerce-register')) {
$username = 'no' === get_option('woocommerce_registration_generate_username') ? $_POST['username'] : '';
$password = 'no' === get_option('woocommerce_registration_generate_password') ? $_POST['password'] : '';
$email = $_POST['email'];
try {
$validation_error = new WP_Error();
$validation_error = apply_filters('woocommerce_process_registration_errors', $validation_error, $username, $password, $email);
if ($validation_error->get_error_code()) {
throw new Exception($validation_error->get_error_message());
}
// Anti-spam trap
if (! empty($_POST['email_2'])) {
throw new Exception(__('Anti-spam field was filled in.', 'woocommerce'));
}
$new_customer = wc_create_new_customer(sanitize_email($email), wc_clean($username), $password);
if (is_wp_error($new_customer)) {
throw new Exception($new_customer->get_error_message());
}
if (apply_filters('woocommerce_registration_auth_new_customer', true, $new_customer)) {
wc_set_customer_auth_cookie($new_customer);
}
wp_safe_redirect(apply_filters('woocommerce_registration_redirect', wp_get_referer() ? wp_get_referer() : wc_get_page_permalink('myaccount')));
exit;
} catch (Exception $e) {
wc_add_notice('<strong>' . __('Error', 'woocommerce') . ':</strong> ' . $e->getMessage(), 'error');
}
}
}
和DIV
<div class="alert success">
<span class="closebtn">×</span>
<strong>Registration Success!</strong> Check Email.
</div>
,这是JS代码
jQuery('input.btn.btn-default.size-new-account').click(function() {
jQuery('.alert.success').show();
});
但问题,我怎么能理解流动为注册,我可以使用条件或其他方式。所以notif会显示验证是否成功,并在加载页面后显示。
您可以添加ID,以及如果你想 –
我没有太多在PHP上的经验,我真的不能发布大部分发布的代码。所以我想直接问一下。上面的脚本允许你注册并重定向到另一个页面或重新加载同一页面吗? – Sagar
实际上在注册过程中它的好, 问题只是,当我点击按钮,即使我留下一切空白的通知仍然显示,因为我只是设置功能onclick。即使该过程未能注册,成功通知将显示 – Reza