Adding filters for contact info and member name and type
authorlaury <laury@gaslightmedia.com>
Fri, 12 Jan 2018 20:34:47 +0000 (15:34 -0500)
committerlaury <laury@gaslightmedia.com>
Fri, 12 Jan 2018 20:34:47 +0000 (15:34 -0500)
Added glma_get_logged_in_contact, glma_get_member_type, and
glma_get_member_name in order for this information to be displayed
more easily on the front end without exposing the config array
(which also contains the user password). This was added in order to
show this info in the MiGCSA header member box.

setup/frontHooks.php

index a47d45b..0873397 100644 (file)
@@ -369,6 +369,26 @@ add_filter('glm_associate_phone_filter', function( $phone ){
     // Passing phone to Plugin Support Function
     return glmMembersFilterPhone( $this->config, $phone );
 });
+add_filter('glma_get_logged_in_contact', function() {
+    $contactUser = $this->config["loggedInUser"]["contactUser"];
+    if ( !$contactUser ) {
+        $contactUser = false;
+    }
+    return $contactUser;
+});
+add_filter('glma_get_member_type', function( $id ){
+    // Passing phone to Plugin Support Function
+    global $wpdb;
+    $type = $wpdb->get_var( "SELECT name FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_type WHERE id = "
+            . "(SELECT member_type FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "members WHERE id = $id) " );
+    return $type;
+});
+add_filter('glma_get_member_name', function( $id ){
+    // Passing phone to Plugin Support Function
+    global $wpdb;
+    $type = $wpdb->get_var( "SELECT name FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "members WHERE id = $id" );
+    return $type;
+});
 
 function get_member_name( $id = 0 ) {
     global $wpdb;