From c30a9514ccca4bab261b175b95c257fed0344a7c Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Mon, 27 Feb 2017 14:33:41 -0500 Subject: [PATCH] Add filter for moderated checks Adding filter to tell if the member is moderated and also call the contact filter to see if the contact is moderated. --- classes/glmPluginSupport.php | 27 +++++++++++++++++++++++++++ setup/adminHooks.php | 15 +++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/classes/glmPluginSupport.php b/classes/glmPluginSupport.php index 01a6138e..873022ff 100644 --- a/classes/glmPluginSupport.php +++ b/classes/glmPluginSupport.php @@ -571,3 +571,30 @@ function glmMembersFilterPhone( $config, $phone ) return $filteredNumber; } +/** + * glmIsMemberModerated + * + * Checks the Member Record to see if changes should be moderated. + * + * @param mixed $config Config Array + * @param mixed $wpdb Word Press DB Object + * @param mixed $memberID Members Id + * + * @access public + * @return boolean + */ +function glmIsMemberModerated( $config, $wpdb, $memberID ) +{ + // Check the members access. If it is moderated then return true. + $access = $wpdb->get_var( + $wpdb->prepare( + "SELECT access FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members WHERE id = %d", + $memberID + ) + ); + if ( $access && !in_array( $access, array( $config['access_numb']['Full'], $config['access_numb']['NotDisplayedNotModerated'] ) ) ) { + return true; + } else { + return false; + } +} diff --git a/setup/adminHooks.php b/setup/adminHooks.php index 85dbbaf8..c8d1bb6c 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -266,3 +266,18 @@ add_filter('glm_associate_phone_filter', function( $phone ){ return glmMembersFilterPhone( $this->config, $phone ); }); +add_filter( 'glm_user_is_moderated', function( $memberID ){ + // check to see if the contact is moderated first. + $contactIsModerated = apply_filters( 'glm_contact_is_moderated', $this->config['loggedInUser'] ); + if ( $contactIsModerated ) { + return true; + } + // check to see if the Member is moderated. + if ( glmIsMemberModerated( $this->config, $this->wpdb, $memberID ) ) { + return true; + } else { + // if you reach here then not moderated + return false; + } +} ); + -- 2.17.1