Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- 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 get_permalink(woocommerce_get_page_id('myaccount'));
- }
- else{
- wp_logout();
- return get_permalink(woocommerce_get_page_id('myaccount')) . "?approved=false";
- }
- }
- }
- function registration_message(){
- if( isset($_REQUEST['approved']) ){
- $approved = $_REQUEST['approved'];
- if ($approved == 'false') { echo '<ul class="woocommerce-info"><li><strong>Sucesso!</strong> Você será notificado quando seu acesso for liberado.</li></ul>';
- }
- }
- }
- add_action('woocommerce_before_customer_login_form', 'registration_message', 2);
- add_action('woocommerce_registration_redirect', 'user_autologout', 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement