1. Home
  2. Docs
  3. Pro and Free
  4. For Developers

For Developers

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();
}
}
}
Was this article helpful to you? Yes No

How can we help?