$start = 1;
$limit = 20; // Set to the number of listings per page
$namesList = false;
+ $CFSelect = false;
+ $CFHeaders = false;
// Check selected fields
$select = array(
'exportViews' => $this->checkFlag('exportViews')
);
+ // Check for selection of Custom Fields
+ $fieldPluginActive = apply_filters( 'glm-members-customfields-active', false );
+ if ( $fieldPluginActive ) {
+ $customFields = apply_filters( 'glm-member-db-fields-get-members-fields', false, 'glm-member-db' );
+ if ( $customFields ) {
+ foreach ( $customFields as $cf ) {
+ if ( isset( $_REQUEST['exportCF'][$cf['id']] ) ) {
+ $CFSelect[] = $cf['id'];
+ $CFHeaders[] = $cf['field_name'];
+ }
+ }
+ }
+ }
+
// Only return information records that are active
// Check if this is a request to show archived members
FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "categories C
ORDER BY C.parent,C.name";
$category_data = $this->wpdb->get_results( $sql, ARRAY_A );
- //echo '<pre>$category_data: ' . print_r( $category_data, true ) . '</pre>';
- // echo '<pre>$where: ' . print_r( $where, true ) . '</pre>';
// Get a current list of members without paging
$list = $this->getList($where, "member_name");
- // echo '<pre>$count: ' . print_r( count($list), true ) . '</pre>';
-
- // echo '<pre>$list: ' . print_r( $list, true ) . '</pre>';
- // exit;
-
// If we have list entries - even if it's an empty list
$success = true;
$haveMembers = false;
$haveMembers = true;
+ // If Custom Fields are selected
+ if ( $CFSelect && !empty( $CFSelect ) ) {
+
+ foreach( $list as $k => $v ) {
+ foreach ( $CFSelect as $cf_key => $cf_id ) {
+ $list[$k][$CFHeaders[$cf_key]] = apply_filters( 'glm_custom_fields_by_entity_id', $CFHeaders[$cf_key], $v['id'] );
+ }
+ }
+
+ }
+
// If URL Clicks and/or Views are selected
if ($select['exportClicks'] || $select['exportViews']) {
}
}
+ // echo '<pre>$list: ' . print_r( $list, true ) . '</pre>';
+ // exit;
+
// Compile template data
$templateData = array(
'category_data' => $category_data,
'nextStart' => $nextStart,
'start' => $start,
'limit' => $limit,
- 'namesList' => $namesList
+ 'namesList' => $namesList,
+ 'CFSelect' => $CFSelect,
+ 'CFHeaders' => $CFHeaders,
);
$view = 'admin/ajax/membersListExport.html';
{if $select.exportPriContactName}<th align="left">Primary Contact</th>{/if}
{if $select.exportPriContactEmail}<th align="left">Primary Contact E-Mail</th>{/if}
{if $select.exportUrl}<th align="left">Web Address</th>{/if}
+ {if $CFHeaders}{foreach $CFHeaders as $cHead}<th align="left">{$cHead}</th>{/foreach}{/if}
{if $select.exportCategories}
{if $category_data}
{foreach $category_data as $cat}
{if $select.exportPriContactName}<td>{if $m.primary_contact}{$m.primary_contact.fname} {$m.primary_contact.lname}{/if}</td>{/if}
{if $select.exportPriContactEmail}<td>{if $m.primary_contact}{$m.primary_contact.email}{/if}</td>{/if}
{if $select.exportUrl}<td>{$m.url}</td>{/if}
+ {if $CFHeaders}{foreach $CFHeaders as $cHead}<td>{$m[$cHead]}</td>{/foreach}{/if}
{if $select.exportCategories}
{if $category_data}
{foreach $category_data as $cat}
{if $select.exportPriContactName}"Pri Contact",{/if}
{if $select.exportPriContactEmail}"Pri Contact E-Mail",{/if}
{if $select.exportUrl}"Web Address",{/if}
+{if $CFHeaders}{foreach $CFHeaders as $cHead}"{$cHead}",{/foreach}{/if}
{if $select.exportCategories} {if $category_data} {foreach $category_data as $cat} "{if $cat.parent_name}{$cat.parent_name}:{/if}{$cat.name}" {if !$cat@last},{/if} {/foreach} {/if} {/if}
{foreach $members as $m}
{if $select.exportPriContactName}"{if $m.primary_contact}{$m.primary_contact.fname} {$m.primary_contact.lname}{/if}",{/if}
{if $select.exportPriContactEmail}"{if $m.primary_contact}{$m.primary_contact.email}{/if}",{/if}
{if $select.exportUrl}"{$m.url}",{/if}
+{if $CFHeaders}{foreach $CFHeaders as $cHead}"{$m[$cHead]}",{/foreach}{/if}
{if $select.exportCategories} {if $category_data} {foreach $category_data as $cat} {$cat_exists='""'} {foreach $m.categories as $t} {if $t.id == $cat.id}{$cat_exists='"Yes"'}{/if} {/foreach} {$cat_exists} {if !$cat@last},{/if} {/foreach} {/if} {/if}
{/foreach}