Add filter for billing
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 9 Jul 2019 12:15:24 +0000 (08:15 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 9 Jul 2019 12:15:24 +0000 (08:15 -0400)
This filter is used in billing to get contact data for notices.

setup/commonHooks.php

index b3194ec..fefb19e 100755 (executable)
@@ -81,4 +81,21 @@ add_filter( 'glm_contact_update_user_role_by_ref_dest', function( $content, $ref
     }
     return $content;
 }, 10, 4);
-?>
+add_filter( 'glm-member-db-contacts-get-contact-data-by-refdest', function( $ref_dest ){
+    require_once GLM_MEMBERS_CONTACTS_PLUGIN_CLASS_PATH . '/data/dataContacts.php';
+    $contactData = new GlmDataContacts( $this->wpdb, $this->config );
+    $contact_id  = $this->wpdb->get_var(
+        $this->wpdb->prepare(
+            "SELECT id
+               FROM " . GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . "contacts
+              WHERE ref_dest = %d",
+            $ref_dest
+        )
+    );
+    if ( $contact_id ) {
+        $contacts    = $contactData->getEntry( $contact_id );
+    } else {
+        $contacts = array();
+    }
+    return $contacts;
+} );