require_once(GLM_MEMBERS_CONTACTS_PLUGIN_SETUP_PATH.'/permissions.php');
/*
- * Notification to user if logging in with restricted contact
+ * Notification to user if logging in with restricted or inactive contact
*/
-$wpUserID = get_current_user_id();
function glmMembersContactsNoLoginMessage( $message ) {
$message .= "
<div style=\"border-left:4px solid #dd3d36;background:#fff;box-shadow:0 1px 1px 0 rgba(0,0,0,.1);padding-left: .5em;\">
- <b>NOTE:</b> 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.
+ <p><b>NOTE:</b> You are trying to log into a contact account that is for informational purposes only
+ or has been temporarily dissabled.</p>
+ <p style=\"margin-top: 1em;\">You are not permitted to log in with that contact account at this time.</p>
</div>
";
return $message;
}
-/*
-$restrictedLoginAttempt = get_user_meta($wpUserID, 'glmMembersDatabaseContactRestrictedLogin', false);
-if ($restrictedLoginAttempt) {
+// 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');
- delete_user_mega($wpUserID, 'glmMembersDatabaseContactRestrictedLogin');
+ 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')) {
- update_user_meta($wpUserID, 'glmMembersDatabaseContactRestrictedLogin', true);
+ setcookie ("glmMembersForcedLogout", "stuff", time() + 3600, '/');
wp_logout();
}
-*/
-/*
- * Check for a contact user that's inactive and send them back to login also
- */
-/*
+// 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) {
- update_user_meta($wpUserID, 'glmMembersDatabaseContactRestrictedLogin', true);
+ setcookie ("glmMembersForcedLogout", "stuff", 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;
Hook to test if the logged in user is permitted to edit a contact.
</td>
</tr>
+ <tr>
+ <td>glm_members_current_logged_in_user</td>
+ <td>Filter</td>
+ <td></td>
+ <td>
+ Filter that returns the current WordPress user data along with any
+ current Member Contact user information. The information returned
+ is listed below
+<pre>Array
+(
+ [wpUser] => Array
+ (
+ [ID] (numeric)
+ [user_login]
+ [user_pass] (encrypted)
+ [user_nicename]
+ [user_email]
+ [user_url]
+ [user_registered] (date)
+ [user_activation_key]
+ [user_status] => 0
+ [display_name] => George Tootikian
+ )
+ [contactUser] => Array
+ (
+ [ID] => (numeric)
+ [fname]
+ [lname]
+ [email]
+ [ref_type] (numeric: 10 = Member contact)
+ [ref_type_name]
+ [ref_dest] (id of reference destination - if type = 10 this is member ID)
+ [ref_dest_name]
+ [role] (Wordpress role ID)
+ [role_name]
+ [access] (see "Member Access Levels" in glm-member-db/config/plugin.ini))
+ [access_name]
+ )
+
+)</pre>
+ </td>
+ </tr>
+ <tr>
+ <td>glm_members_locked_to_member_id</td>
+ <td>Filter</td>
+ <td></td>
+ <td>
+ Filter that provides the member ID of any member the current user is locked into.
+ </td>
+ </tr>
+ <tr>
+ <td>glm_members_menu_members</td>
+ <td>Filter</td>
+ <td></td>
+ <td>
+ Returns boolean answer to "Can current user access any member?"
+ </td>
+ </tr>
+ <tr>
+ <td>glm_members_permit_admin_members_index_member_config_warning</td>
+ <td>Filter</td>
+ <td></td>
+ <td>
+ Returns boolean answer to "Should we display configuration warnings to current user?"
+ </td>
+ </tr>
+ <tr>
+ <td>glm_members_permit_admin_members_index_add_member</td>
+ <td>Filter</td>
+ <td></td>
+ <td>
+ Returns boolean answer to "Can current user edit any member?"
+ </td>
+ </tr>
+ <tr>
+ <td>glm_members_permit_admin_member_index_add_member_info_version</td>
+ <td>Filter</td>
+ <td></td>
+ <td>
+ Returns boolean answer to "Should current user see the member information display and add-new links/buttons?"
+ </td>
+ </tr>
+ <tr>
+ <td>glm_members_permit_admin_member_index_edit_member</td>
+ <td>Filter</td>
+ <td></td>
+ <td>
+ Returns boolean answer to "Should current user see the member edit page?" (if not, then just show the info)
+ </td>
+ </tr>
+ <tr>
+ <td>glm_members_permit_admin_member_index_view_member_info_version</td>
+ <td>Filter</td>
+ <td></td>
+ <td>
+ Returns boolean answer to "Should current user see link to view/edit member information?"
+ </td>
+ </tr>
+ <tr>
+ <td>glm_members_permit_admin_member_index_clone_activate_info_version</td>
+ <td>Filter</td>
+ <td></td>
+ <td>
+ Returns boolean answer to "Should current user see Clone and Activate buttons for member information?"
+ </td>
+ </tr>
+ <tr>
+ <td>glm_members_permit_admin_member_contacts_tab</td>
+ <td>Filter</td>
+ <td></td>
+ <td>
+ Returns boolean answer to "Should current user see the Contacts tab?"
+ </td>
+ </tr>
+ <tr>
+ <td>glm_members_permit_admin_member_contacts_add_contact</td>
+ <td>Filter</td>
+ <td></td>
+ <td>
+ Returns boolean answer to "Should current user be able to add contacts?"
+ </td>
+ </tr>
+ <tr>
+ <td>glm_members_permit_admin_member_contacts_view_contact</td>
+ <td>Filter</td>
+ <td></td>
+ <td>
+ Returns boolean answer to "Should current user be able to view contact data?"
+ </td>
+ </tr>
+ <tr>
+ <td>glm_members_permit_admin_member_contacts_edit_contact</td>
+ <td>Filter</td>
+ <td></td>
+ <td>
+ Returns boolean answer to "Should current user be able to edit contact data?"
+ </td>
+ </tr>
+ <tr>
+ <td>glm_members_permit_admin_widget_members</td>
+ <td>Filter</td>
+ <td></td>
+ <td>
+ Returns boolean answer to "Should current user see the member search and member list in dashboard widget?"
+ </td>
+ </tr>
+ <tr>
+ <td>glm_members_permit_admin_widget_warnings</td>
+ <td>Filter</td>
+ <td></td>
+ <td>
+ Returns boolean answer to "Should current user see warnings in dashboard widget?"
+ </td>
+ </tr>
+ <tr>
+ <td>glm_members_permit_admin_widget_pending_info</td>
+ <td>Filter</td>
+ <td></td>
+ <td>
+ Returns boolean answer to "Should current user see pending member information list in dashboard widget?"
+ </td>
+ </tr>
+ <tr>
+ <td>glm_members_permit_admin_member_index_list_inactive_info</td>
+ <td>Filter</td>
+ <td></td>
+ <td>
+ Returns boolean answer to "Should current user see inactive member information records in member info list?"
+ </td>
+ </tr>
+ <tr>
+ <td>glm_members_permit_admin_member_info_edit</td>
+ <td>Filter</td>
+ <td></td>
+ <td>
+ Returns boolean answer to "Should current user be able to edit member information records?"
+ </td>
+ </tr>
+ <tr>
+ <td>glm_members_permit_admin_profile_index_edit_profile</td>
+ <td>Filter</td>
+ <td></td>
+ <td>
+ Returns boolean answer to "Should current user be able to edit own contact profile?"
+ </td>
+ </tr>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
add_filter('glm_members_current_logged_in_user',
function($loggedInUser) {
- global $wpdb;
+ global $wpdb, $config;
+
// Add default of no current contact user
$loggedInUser['contactUser'] = false;
}
// Try to get the matching contact data
- $contactInfo = $wpdb->get_row("SELECT * FROM ".GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . "contacts WHERE id = $contactID;");
+// $contactInfo = $wpdb->get_row("SELECT * FROM ".GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . "contacts WHERE id = $contactID;");
+
+ require_once(GLM_MEMBERS_CONTACTS_PLUGIN_CLASS_PATH.'/data/dataContacts.php');
+ $ContactInfo = new GlmDataContacts($wpdb, $config);
+ $contactInfo = $ContactInfo->getEntry($contactID);
// If contact is not active, then return false - should not be logged in
- if (!$contactInfo->active) {
+ if (!$contactInfo['active']['value']) {
return false;
}
// Return array with base data on this contact that might be needed by this add-on
$loggedInUser['contactUser'] = array(
'ID' => $contactID,
- 'fname' => $contactInfo->fname,
- 'lname' => $contactInfo->lname,
- 'email' => $contactInfo->email,
- 'ref_type' => $contactInfo->ref_type,
- 'ref_dest' => $contactInfo->ref_dest,
- 'role' => $contactInfo->contact_role,
- 'access' => $contactInfo->access
+ 'fname' => $contactInfo['fname'],
+ 'lname' => $contactInfo['lname'],
+ 'email' => $contactInfo['email'],
+ 'ref_type' => $contactInfo['ref_type']['value'],
+ 'ref_type_name' => $contactInfo['ref_type']['name'],
+ 'ref_dest' => $contactInfo['ref_dest'],
+ 'ref_dest_name' => $contactInfo['ref_dest_name'],
+ 'role' => $contactInfo['contact_role']['value'],
+ 'role_name' => $contactInfo['contact_role']['name'],
+ 'access' => $contactInfo['access']['value'],
+ 'access_name' => $contactInfo['access']['name']
);
+
return $loggedInUser;
}
);
}
);
-// glm-member-db, view/member/contacts.html, Display Contacts tab
+// glm-member-db, view/member/contacts.html, Add Contacts data
add_filter('glm_members_permit_admin_member_contacts_add_contact',
function($permit) {
if (!$permit) { return false; }