脚本宝典收集整理的这篇文章主要介绍了php – 在woocommerce中注册并重定向到登录页面时阻止自动登录?,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
如何在未登录的情况下成功注册后,如何将注册页面重定向到登录页面.用户需要使用通过电子邮件发送的用户名和密码登录.
www.example.com/my-account/?action=register
/* Stop auto login */ function user_autologout(){ if ( is_user_LOGged_in() ) { $current_user = wp_get_current_user(); $user_id = $current_user->ID; $apPRoved_status = get_user_Meta($user_id,'wp-approve-user',true); //if the user hasn't been approved yet by WP Approve User plugin,destroy the cookie to kill the session and log them out if ( $approved_status == 1 ){ return $redirect_url; } else{ wp_logout(); return get_PErmalink(woocommerce_get_page_id('myaccount')) . "?approved=false"; } } } add_action('woocommerce_registration_redirect','user_autologout',2); function registration_message(){ $not_approved_message = '<p class="registration">Send in your registration application today!<br /> NOTE: Your account will be held for moderation and you will be unable to login until IT is approved.</p>'; if( isset($_REQUEST['approved']) ){ $approved = $_REQUEST['approved']; if ($approved == 'false') echo '<p class="registration successful">Registration successful! You will be notified upon approval of your account.</p>'; else echo $not_approved_message; } else echo $not_approved_message; } add_action('woocommerce_before_customer_login_form','registration_message',2);
以上是脚本宝典为你收集整理的php – 在woocommerce中注册并重定向到登录页面时阻止自动登录?全部内容,希望文章能够帮你解决php – 在woocommerce中注册并重定向到登录页面时阻止自动登录?所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。