From: Anthony Talarico Date: Thu, 18 Jan 2018 15:19:27 +0000 (-0500) Subject: adding front hook to get active member info id on the front end X-Git-Tag: v2.10.23^2~23^2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=48134fe5fc3bfb76be555792a28b02c51078f56b;p=WP-Plugins%2Fglm-member-db.git adding front hook to get active member info id on the front end needed hook that gets the active member info id in the theme --- diff --git a/setup/frontHooks.php b/setup/frontHooks.php index 08733977..4e6de1df 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -49,6 +49,42 @@ add_action('wp_loaded', function() { } } }); +/* +* Find the active member info record ID for a specific member ID +* +* @param integer $member ID of the member name +* @param string $where Optional WHERE clause for query +* +* @return integer Member info record ID or false if not found +*/ +add_filter('getActiveInfoIdForMember', function($member, $where = 'true') { + + $memberID = $member - 0; + + $sql = " + SELECT T.id + FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "member_info T + WHERE $where + AND member = $memberID + AND status = ".$this->config['status_numb']['Active']." + AND ( + SELECT access + FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."members + WHERE id = T.member + ) IN ( + ".$this->config['access_numb']['NoAccess'].", + ".$this->config['access_numb']['Moderated'].", + ".$this->config['access_numb']['Full']." + ) + "; + $memberInfo = $this->wpdb->get_row($sql, ARRAY_A); + + if ($memberInfo) { + return $memberInfo['id']; + } + + return false; +}); /* * Add a filter to correct rel_canonical header entries