setcookie ("glmMembersForcedLogout", "", time() - 3600);
}
-// Check if user's only role is as a restricted contact
-$userRoles = get_userdata($wpUserID)->roles;
-if (in_array('glm_members_restricted_contact', $userRoles) && count($userRoles) == 1) {
- setcookie ("glmMembersForcedLogout", "Forced Logout", time() + 3600, '/');
- wp_logout();
-}
+if ($wpUserID) {
+
+ // Check if user's only role is as a restricted contact
+ $userRoles = get_userdata($wpUserID)->roles;
+ if (in_array('glm_members_restricted_contact', $userRoles) && count($userRoles) == 1) {
+ setcookie ("glmMembersForcedLogout", "Forced Logout", time() + 3600, '/');
+ wp_logout();
+ }
+
+ // Check for a contact user that's inactive and send them back to login also
+ $contactUser = get_user_meta($wpUserID, 'glmMembersContactID', true);
+ $contactActive = get_user_meta($wpUserID, 'glmMembersContactActive', true);
+ if ($contactUser && !$contactActive) {
+ setcookie ("glmMembersForcedLogout", "Forced Logout", time() + 3600, '/');
+ wp_logout();
+ }
-// Check for a contact user that's inactive and send them back to login also
-$contactUser = get_user_meta($wpUserID, 'glmMembersContactID', true);
-$contactActive = get_user_meta($wpUserID, 'glmMembersContactActive', true);
-if ($contactUser && !$contactActive) {
- setcookie ("glmMembersForcedLogout", "Forced Logout", time() + 3600, '/');
- wp_logout();
}
/*