From: Steve Sutton Date: Tue, 17 Apr 2018 17:52:01 +0000 (-0400) Subject: Update export to get new custom field data X-Git-Tag: v1.0.0^2~22 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=2fc63d29d4b20e9751ff290ca634de385a19bdf1;p=WP-Plugins%2Fglm-member-db-registrations.git Update export to get new custom field data Getting the custom field data for the level. --- diff --git a/classes/data/dataRegRequestRegistrant.php b/classes/data/dataRegRequestRegistrant.php index 10d325b..4ce6be4 100644 --- a/classes/data/dataRegRequestRegistrant.php +++ b/classes/data/dataRegRequestRegistrant.php @@ -352,8 +352,8 @@ class GlmDataRegistrationsRequestRegistrant extends GlmDataAbstract if ( $customFieldsPluginActive ) { $custom_data = array(); // Check if there's custom field data for this record - $fid = 'glm_reg_customfields_reg_event_attendee_' . $eventId; - $recordId = $registrantVal['id']; + $fid = 'glm_reg_customfields_reg_event_attendee_' . $eventId; + $recordId = $registrantVal['id']; $customData = apply_filters( 'glm-members-customfields-form-data-recall', '', $fid, $recordId, false ); // echo '
$customData: ' . print_r( $customData, true ) . '
'; if ( isset( $customData ) && is_array( $customData ) && !empty( $customData ) ) { @@ -361,13 +361,41 @@ class GlmDataRegistrationsRequestRegistrant extends GlmDataAbstract foreach ( $fields as $cField ) { $custom_data[$cField['field_name']] = $cField['stored']; } - $registrants[$registrantKey]['custom_data'] = $custom_data; } + // Check for level custom fields also + // Find all reg_class for this event + $reg_classes = $this->wpdb->get_results( + $this->wpdb->prepare( + "SELECT id + FROM " . GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "reg_class + WHERE reg_event = %d", + $eventId + ), + ARRAY_A + ); + if ( $reg_classes ) { + foreach ( $reg_classes as $class ) { + $fid = 'glm_reg_customfields_reg_event_' . $eventId . '_level_' . $class['id']; + $customLevelData = apply_filters( 'glm-members-customfields-form-data-recall', '', $fid, $recordId, false ); + // echo '
$customLevelData: ' . print_r( $customLevelData, true ) . '
'; + if ( isset( $customLevelData ) && is_array( $customLevelData ) && !empty( $customLevelData ) ) { + $fields = $customLevelData['form']; + foreach ( $fields as $cField ) { + $custom_data[$cField['field_name']] = $cField['stored']; + } + } + } + } + + // Add custom field data to registrants + $registrants[$registrantKey]['custom_data'] = $custom_data; + // echo '
$registrants: ' . print_r( $registrants, true ) . '
'; + } // Try to get any per } - $listResult['list'] = $registrants; + $listResult['list'] = $registrants; $listResult['totalCount'] = $registrantCount; return $listResult; diff --git a/models/admin/registrations/events_registrants.php b/models/admin/registrations/events_registrants.php index e351e04..58c03d6 100644 --- a/models/admin/registrations/events_registrants.php +++ b/models/admin/registrations/events_registrants.php @@ -63,6 +63,7 @@ $customFieldsPluginActive = apply_filters( 'glm-members-customfields-plugin-acti $listResult = $Registrants->getFullRegistrantsData($regEventID, $where, $start, $limit); // echo '
$listResult: ' . print_r( $listResult['list'], true ) . '
'; + // Get count of registrants listed $registrantCount = $listResult['totalCount'];