From: Chuck Scott Date: Tue, 26 Jan 2016 21:09:13 +0000 (-0500) Subject: Fixed up user logout detection and messaging. X-Git-Tag: v1.0.8~3^2~1 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=137012009eaa7115d0ffc3954dc81afb5ca07232;p=WP-Plugins%2Fglm-member-db-contacts.git Fixed up user logout detection and messaging. --- diff --git a/glm-member-db-contacts.php b/glm-member-db-contacts.php index e44672d..c15097b 100644 --- a/glm-member-db-contacts.php +++ b/glm-member-db-contacts.php @@ -32,20 +32,11 @@ * made together with the DB_VERSION below. ONLY bump the DB * version when there's a change in the database!! Use the * version nunmber of that release for the DB version. - * - * We check the plugin version stored in the WordPress option below - * so that we're sure the other add-ons see an up to date - * version from this plugin. */ define('GLM_MEMBERS_CONTACTS_PLUGIN_VERSION', '1.0.7'); define('GLM_MEMBERS_CONTACTS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '1.0.44'); define('REQUIRED_GLM_MEMBERS_PLUGIN_MIN_DB_VERSION', '1.0.41'); -// Check if plugin version is not current in WordPress option and if needed updated it -if (GLM_MEMBERS_CONTACTS_PLUGIN_VERSION != get_option('glmMembersDatabaseContactsPluginVersion')) { - update_option('glmMembersDatabaseContactsPluginVersion', GLM_MEMBERS_CONTACTS_PLUGIN_VERSION); -} - /* * Copyright 2014 Charles Scott (email : cscott@gaslightmedia.com) * @@ -182,43 +173,49 @@ add_filter('glm-member-db-register-addon','glmMembersRegisterContacts', 10, 1); require_once(GLM_MEMBERS_CONTACTS_PLUGIN_SETUP_PATH.'/permissions.php'); /* - * Notification to user if logging in with restricted or inactive contact + * Login Checks and Messages */ + +$wpUserID = get_current_user_id(); + +// Message to display on Login page after a forced logout detection function glmMembersContactsNoLoginMessage( $message ) { $message .= "

NOTE: You are trying to log into a contact account that is for informational purposes only - or has been temporarily dissabled.

-

You are not permitted to log in with that contact account at this time.

+ or has been temporarily dissabled.

+

You are not permitted to log in with that contact account at this time.

"; return $message; } -/* + // If login is from user who was logged out due to restriction or being flagged inactive - Display login message if (isset($_COOKIE['glmMembersForcedLogout'])) { add_filter('login_message', 'glmMembersContactsNoLoginMessage'); setcookie ("glmMembersForcedLogout", "", time() - 3600); } -// Check for a restricted contact user and log them out with login message -if (current_user_can('glm_members_restricted_contact')) { - setcookie ("glmMembersForcedLogout", "stuff", 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(); } + // Check for a contact user that's inactive and send them back to login also -$wpUserID = get_current_user_id(); $contactUser = get_user_meta($wpUserID, 'glmMembersContactID', true); $contactActive = get_user_meta($wpUserID, 'glmMembersContactActive', true); if ($contactUser && !$contactActive) { - setcookie ("glmMembersForcedLogout", "stuff", time() + 3600, '/'); + setcookie ("glmMembersForcedLogout", "Forced Logout", time() + 3600, '/'); wp_logout(); } -*/ /* * Add filter to redirect user to a particular destination on * login based on their roles. */ + function my_login_redirect( $redirect_to, $request, $user ) { global $user; diff --git a/setup/rolesAndCapabilities.php b/setup/rolesAndCapabilities.php index 045ea30..25c6c62 100644 --- a/setup/rolesAndCapabilities.php +++ b/setup/rolesAndCapabilities.php @@ -24,11 +24,13 @@ */ // *** TEMPORARY TO REMOVE OLD ROLSES +/* remove_role('glm_own_member_manager'); remove_role('glm_own_entity_manager'); remove_role('glm_member_contact'); remove_role('glm_member_restricted_contact'); remove_role('glm_members_own_member_manager'); +*/ /* // Un-comment to fully reset all contact roles