简体   繁体   中英

How to automatically logout after register in wordpress?

Now in my wordpress website after the user is registering is redirected to my account page (i use woocommerce).

I want hime to be logged out automatically after register.

Because I want to approve it first.

This is the code:

if (is_user_logged_in()) {
    $nua = pw_new_user_approve();
    $status = $nua->get_user_status(get_current_user_id());
    if ($status === 'pending') {?>
        HERE IS THE FUNCTION TO LOGOUT AUTOMATICALLY!
        <?php

    }
}

Any help please?

<?php
if (is_user_logged_in()) {
    $nua = pw_new_user_approve();
    $status = $nua->get_user_status(get_current_user_id());
    if ($status === 'pending') {
    $redirect = 'sitepath'; 
wp_logout_url($redirect);       

    }
}
?> 

Try this

if (is_user_logged_in()) {
    $nua = pw_new_user_approve();
    $status = $nua->get_user_status(get_current_user_id());
    if ($status === 'pending') {
    wp_logout();
    }
} 

请尝试一下

<?php echo wp_logout_url( $_SERVER['REQUEST_URI'] ); ?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM