Secure an Exclusive 20% Discount on Lifetime Access - Limited Time Offer. Use code: LIFETIME20

For Developers

Estimated reading: 1 minute 287 views

Avoid Automatically Login After Registration

You can use below code snippet to avoid automatically login after the registration.

add_action('init', 'nua_logout_pending_denied_users');
function nua_logout_pending_denied_users(){
$user = wp_get_current_user();  
if ( $user instanceof WP_User && !empty($user->ID) && is_array($user->roles) && !in_array('administrator', $user->roles)){

$user_status = get_user_meta( $user->ID, 'pw_user_status', true );

if ( 'denied' == $user_status || 'pending' == $user_status ) {
wp_logout();

// custom URL to redirect after logout
wp_safe_redirect( home_url() );
exit();
}
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Share this Doc

For Developers

Or copy link

CONTENTS