From: Chuck Scott Date: Tue, 26 Jan 2016 21:23:16 +0000 (-0500) Subject: Fixed error due to accessing user data when no user logged in. X-Git-Tag: v1.0.8~3^2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=1dbdbde5565e0db4edb4746d2e5b20fbdceaf191;p=WP-Plugins%2Fglm-member-db-contacts.git Fixed error due to accessing user data when no user logged in. --- diff --git a/glm-member-db-contacts.php b/glm-member-db-contacts.php index c15097b..c9c2ee3 100644 --- a/glm-member-db-contacts.php +++ b/glm-member-db-contacts.php @@ -196,19 +196,23 @@ if (isset($_COOKIE['glmMembersForcedLogout'])) { 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(); } /*