PHPackages                             arraypress/edd-register-export-columns - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. arraypress/edd-register-export-columns

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

arraypress/edd-register-export-columns
======================================

A library for registering custom export columns in Easy Digital Downloads CSV exports

014PHP

Since Dec 4Pushed 5mo agoCompare

[ Source](https://github.com/arraypress/edd-register-export-columns)[ Packagist](https://packagist.org/packages/arraypress/edd-register-export-columns)[ RSS](/packages/arraypress-edd-register-export-columns/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

EDD Export Columns - Register Custom CSV Export Columns
=======================================================

[](#edd-export-columns---register-custom-csv-export-columns)

Add custom columns to Easy Digital Downloads CSV exports with custom data and calculations.

Installation
------------

[](#installation)

```
composer require arraypress/edd-register-export-columns
```

Basic Usage
-----------

[](#basic-usage)

```
// Add custom columns to customer exports
edd_register_export_columns( 'customers', [
	'lifetime_downloads' => [
		'label'    => 'Total Downloads',
		'callback' => function ( $customer_id ) {
			return edd_count_file_downloads_of_customer( $customer_id );
		}
	],
	'last_login'         => [
		'label'    => 'Last Login',
		'callback' => function ( $customer_id ) {
			$customer = new EDD_Customer( $customer_id );
			if ( ! $customer->user_id ) {
				return 'N/A';
			}

			$last_login = get_user_meta( $customer->user_id, 'last_login', true );

			return $last_login ? date( 'Y-m-d H:i:s', $last_login ) : 'Never';
		}
	],
	'support_tickets'    => [
		'label'    => 'Support Tickets',
		'callback' => function ( $customer_id ) {
			$customer = new EDD_Customer( $customer_id );

			return get_user_meta( $customer->user_id, 'support_ticket_count', true ) ?: 0;
		}
	]
] );

// Add custom columns to download exports
edd_register_export_columns( 'downloads', [
	'total_reviews'  => [
		'label'    => 'Reviews',
		'callback' => function ( $download_id ) {
			return get_comments_number( $download_id );
		}
	],
	'average_rating' => [
		'label'    => 'Avg Rating',
		'callback' => function ( $download_id ) {
			$reviews = get_comments( [
				'post_id'  => $download_id,
				'meta_key' => 'rating',
				'fields'   => 'ids'
			] );

			if ( empty( $reviews ) ) {
				return 'N/A';
			}

			$total_rating = 0;
			foreach ( $reviews as $review_id ) {
				$total_rating += (int) get_comment_meta( $review_id, 'rating', true );
			}

			return round( $total_rating / count( $reviews ), 2 );
		}
	],
	'custom_field'   => [
		'label'    => 'Custom Field',
		'callback' => function ( $download_id ) {
			return get_post_meta( $download_id, 'my_custom_field', true );
		}
	]
] );
```

Real Examples
-------------

[](#real-examples)

```
function add_export_columns() {
	// Customer export columns
	$customer_columns = [];

	// Add WooCommerce data if available
	if ( class_exists( 'WooCommerce' ) ) {
		$customer_columns['woo_orders'] = [
			'label'    => 'WooCommerce Orders',
			'callback' => function ( $customer_id ) {
				$customer = new EDD_Customer( $customer_id );

				return $customer->user_id ? wc_get_customer_order_count( $customer->user_id ) : 0;
			}
		];

		$customer_columns['woo_total_spent'] = [
			'label'    => 'WooCommerce Total Spent',
			'callback' => function ( $customer_id ) {
				$customer = new EDD_Customer( $customer_id );

				return $customer->user_id ? wc_get_customer_total_spent( $customer->user_id ) : 0;
			}
		];
	}

	// Add subscription data
	if ( class_exists( 'EDD_Recurring' ) ) {
		$customer_columns['active_subscriptions'] = [
			'label'    => 'Active Subscriptions',
			'callback' => function ( $customer_id ) {
				return count( EDD_Recurring()->db->get_subscriptions( [
					'customer_id' => $customer_id,
					'status'      => 'active'
				] ) );
			}
		];
	}

	// Add affiliate data
	if ( function_exists( 'affiliate_wp' ) ) {
		$customer_columns['referrals'] = [
			'label'    => 'Referrals Made',
			'callback' => function ( $customer_id ) {
				$customer     = new EDD_Customer( $customer_id );
				$affiliate_id = affwp_get_affiliate_id( $customer->user_id );

				return $affiliate_id ? affiliate_wp()->referrals->count( [ 'affiliate_id' => $affiliate_id ] ) : 0;
			}
		];
	}

	if ( ! empty( $customer_columns ) ) {
		edd_register_export_columns( 'customers', $customer_columns );
	}

	// Download export columns
	$download_columns = [
		'featured_image'       => [
			'label'    => 'Featured Image URL',
			'callback' => function ( $download_id ) {
				return get_the_post_thumbnail_url( $download_id, 'full' ) ?: '';
			}
		],
		'download_files_count' => [
			'label'    => 'Number of Files',
			'callback' => function ( $download_id ) {
				$files = edd_get_download_files( $download_id );

				return count( $files );
			}
		],
		'total_earnings'       => [
			'label'    => 'Total Earnings',
			'callback' => function ( $download_id ) {
				return edd_get_download_earnings_stats( $download_id );
			}
		],
		'total_sales'          => [
			'label'    => 'Total Sales',
			'callback' => function ( $download_id ) {
				return edd_get_download_sales_stats( $download_id );
			}
		]
	];

	edd_register_export_columns( 'downloads', $download_columns );
}

add_action( 'init', 'add_export_columns' );
```

Parameters
----------

[](#parameters)

ParameterTypeRequiredDescription`$type`string**Yes**Export type ('customers', 'downloads', 'payments', etc.)`$columns`array**Yes**Array of column configurations`$id_field`stringNoID field name (default: 'ID')`$error_callback`callableNoError handling function### Column Configuration

[](#column-configuration)

OptionRequiredDescription`label`**Yes**Column header text`callback`**Yes**Function that returns column valueExport Types
------------

[](#export-types)

Common EDD export types you can extend:

- `customers` - Customer export data
- `downloads` - Download/product export data
- `payments` - Payment/order export data
- `file_downloads` - File download logs
- `customers_export` - Alternative customer export

Requirements
------------

[](#requirements)

- PHP 7.4+
- WordPress 5.0+
- Easy Digital Downloads 3.0+

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

License
-------

[](#license)

This project is licensed under the GPL-2.0-or-later License.

Support
-------

[](#support)

- [Documentation](https://github.com/arraypress/edd-register-export-columns)
- [Issue Tracker](https://github.com/arraypress/edd-register-export-columns/issues)

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance49

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/cd6eb8aff0903d87eb674d1ba3c5f3653899c0d7661504eb0deb7798ed86b643?d=identicon)[arraypress](/maintainers/arraypress)

---

Top Contributors

[![arraypress](https://avatars.githubusercontent.com/u/22668877?v=4)](https://github.com/arraypress "arraypress (2 commits)")

### Embed Badge

![Health badge](/badges/arraypress-edd-register-export-columns/health.svg)

```
[![Health](https://phpackages.com/badges/arraypress-edd-register-export-columns/health.svg)](https://phpackages.com/packages/arraypress-edd-register-export-columns)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
