Update for contact custom fields
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 24 May 2018 18:43:17 +0000 (14:43 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 24 May 2018 18:43:17 +0000 (14:43 -0400)
This will need some more work.

models/admin/import/fields.php

index 68eecc7..e27968c 100644 (file)
@@ -238,9 +238,18 @@ class GlmMembersAdmin_import_fields extends GlmDataFieldsCustomFieldsData
                                 $customRow[0]
                             )
                         );
+                        // We need to get the contact id now
+                        $memberContactId = $this->wpdb->get_var(
+                            $this->wpdb->prepare(
+                                "SELECT id
+                                   FROM " . GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . "contacts
+                                  WHERE ref_dest = %d",
+                                $memberId
+                            )
+                        );
                         // get the active member info id
-                        $memberInfoId =
-                            $memberInfoData->getActiveInfoIdForMember( $memberId );
+                        // $memberInfoId =
+                        //     $memberInfoData->getActiveInfoIdForMember( $memberId );
                         $customFieldId = $this->wpdb->get_var(
                             $this->wpdb->prepare(
                                 "SELECT id
@@ -249,11 +258,11 @@ class GlmMembersAdmin_import_fields extends GlmDataFieldsCustomFieldsData
                                 $customRow[1]
                             )
                         );
-                        if ( $customFieldId ) {
+                        if ( $customFieldId && $memberContactId ) {
                             $newId = $this->wpdb->insert(
                                 GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX .  'custom_field_data',
                                 array(
-                                    'entity_id'  => $memberInfoId,
+                                    'entity_id'  => $memberContactId,
                                     'field_id'   => $customFieldId,
                                     'field_data' => $customRow[2],
                                 ),