{"id":36295698,"url":"https://github.com/arraypress/edd-register-export-columns","last_synced_at":"2026-01-13T23:46:00.869Z","repository":{"id":331827175,"uuid":"1018435736","full_name":"arraypress/edd-register-export-columns","owner":"arraypress","description":"A library for registering custom export columns in Easy Digital Downloads CSV exports.","archived":false,"fork":false,"pushed_at":"2025-12-04T22:11:01.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-11T14:20:33.089Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arraypress.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-12T08:56:10.000Z","updated_at":"2025-12-04T22:11:06.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/arraypress/edd-register-export-columns","commit_stats":null,"previous_names":["arraypress/edd-register-export-columns"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/arraypress/edd-register-export-columns","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fedd-register-export-columns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fedd-register-export-columns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fedd-register-export-columns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fedd-register-export-columns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arraypress","download_url":"https://codeload.github.com/arraypress/edd-register-export-columns/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arraypress%2Fedd-register-export-columns/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28405302,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-11T10:04:42.928Z","updated_at":"2026-01-13T23:46:00.864Z","avatar_url":"https://github.com/arraypress.png","language":"PHP","readme":"# EDD Export Columns - Register Custom CSV Export Columns\n\nAdd custom columns to Easy Digital Downloads CSV exports with custom data and calculations.\n\n## Installation\n\n```bash\ncomposer require arraypress/edd-register-export-columns\n```\n\n## Basic Usage\n\n```php\n// Add custom columns to customer exports\nedd_register_export_columns( 'customers', [\n\t'lifetime_downloads' =\u003e [\n\t\t'label'    =\u003e 'Total Downloads',\n\t\t'callback' =\u003e function ( $customer_id ) {\n\t\t\treturn edd_count_file_downloads_of_customer( $customer_id );\n\t\t}\n\t],\n\t'last_login'         =\u003e [\n\t\t'label'    =\u003e 'Last Login',\n\t\t'callback' =\u003e function ( $customer_id ) {\n\t\t\t$customer = new EDD_Customer( $customer_id );\n\t\t\tif ( ! $customer-\u003euser_id ) {\n\t\t\t\treturn 'N/A';\n\t\t\t}\n\n\t\t\t$last_login = get_user_meta( $customer-\u003euser_id, 'last_login', true );\n\n\t\t\treturn $last_login ? date( 'Y-m-d H:i:s', $last_login ) : 'Never';\n\t\t}\n\t],\n\t'support_tickets'    =\u003e [\n\t\t'label'    =\u003e 'Support Tickets',\n\t\t'callback' =\u003e function ( $customer_id ) {\n\t\t\t$customer = new EDD_Customer( $customer_id );\n\n\t\t\treturn get_user_meta( $customer-\u003euser_id, 'support_ticket_count', true ) ?: 0;\n\t\t}\n\t]\n] );\n\n// Add custom columns to download exports\nedd_register_export_columns( 'downloads', [\n\t'total_reviews'  =\u003e [\n\t\t'label'    =\u003e 'Reviews',\n\t\t'callback' =\u003e function ( $download_id ) {\n\t\t\treturn get_comments_number( $download_id );\n\t\t}\n\t],\n\t'average_rating' =\u003e [\n\t\t'label'    =\u003e 'Avg Rating',\n\t\t'callback' =\u003e function ( $download_id ) {\n\t\t\t$reviews = get_comments( [\n\t\t\t\t'post_id'  =\u003e $download_id,\n\t\t\t\t'meta_key' =\u003e 'rating',\n\t\t\t\t'fields'   =\u003e 'ids'\n\t\t\t] );\n\n\t\t\tif ( empty( $reviews ) ) {\n\t\t\t\treturn 'N/A';\n\t\t\t}\n\n\t\t\t$total_rating = 0;\n\t\t\tforeach ( $reviews as $review_id ) {\n\t\t\t\t$total_rating += (int) get_comment_meta( $review_id, 'rating', true );\n\t\t\t}\n\n\t\t\treturn round( $total_rating / count( $reviews ), 2 );\n\t\t}\n\t],\n\t'custom_field'   =\u003e [\n\t\t'label'    =\u003e 'Custom Field',\n\t\t'callback' =\u003e function ( $download_id ) {\n\t\t\treturn get_post_meta( $download_id, 'my_custom_field', true );\n\t\t}\n\t]\n] );\n```\n\n## Real Examples\n\n```php\nfunction add_export_columns() {\n\t// Customer export columns\n\t$customer_columns = [];\n\n\t// Add WooCommerce data if available\n\tif ( class_exists( 'WooCommerce' ) ) {\n\t\t$customer_columns['woo_orders'] = [\n\t\t\t'label'    =\u003e 'WooCommerce Orders',\n\t\t\t'callback' =\u003e function ( $customer_id ) {\n\t\t\t\t$customer = new EDD_Customer( $customer_id );\n\n\t\t\t\treturn $customer-\u003euser_id ? wc_get_customer_order_count( $customer-\u003euser_id ) : 0;\n\t\t\t}\n\t\t];\n\n\t\t$customer_columns['woo_total_spent'] = [\n\t\t\t'label'    =\u003e 'WooCommerce Total Spent',\n\t\t\t'callback' =\u003e function ( $customer_id ) {\n\t\t\t\t$customer = new EDD_Customer( $customer_id );\n\n\t\t\t\treturn $customer-\u003euser_id ? wc_get_customer_total_spent( $customer-\u003euser_id ) : 0;\n\t\t\t}\n\t\t];\n\t}\n\n\t// Add subscription data\n\tif ( class_exists( 'EDD_Recurring' ) ) {\n\t\t$customer_columns['active_subscriptions'] = [\n\t\t\t'label'    =\u003e 'Active Subscriptions',\n\t\t\t'callback' =\u003e function ( $customer_id ) {\n\t\t\t\treturn count( EDD_Recurring()-\u003edb-\u003eget_subscriptions( [\n\t\t\t\t\t'customer_id' =\u003e $customer_id,\n\t\t\t\t\t'status'      =\u003e 'active'\n\t\t\t\t] ) );\n\t\t\t}\n\t\t];\n\t}\n\n\t// Add affiliate data\n\tif ( function_exists( 'affiliate_wp' ) ) {\n\t\t$customer_columns['referrals'] = [\n\t\t\t'label'    =\u003e 'Referrals Made',\n\t\t\t'callback' =\u003e function ( $customer_id ) {\n\t\t\t\t$customer     = new EDD_Customer( $customer_id );\n\t\t\t\t$affiliate_id = affwp_get_affiliate_id( $customer-\u003euser_id );\n\n\t\t\t\treturn $affiliate_id ? affiliate_wp()-\u003ereferrals-\u003ecount( [ 'affiliate_id' =\u003e $affiliate_id ] ) : 0;\n\t\t\t}\n\t\t];\n\t}\n\n\tif ( ! empty( $customer_columns ) ) {\n\t\tedd_register_export_columns( 'customers', $customer_columns );\n\t}\n\n\t// Download export columns\n\t$download_columns = [\n\t\t'featured_image'       =\u003e [\n\t\t\t'label'    =\u003e 'Featured Image URL',\n\t\t\t'callback' =\u003e function ( $download_id ) {\n\t\t\t\treturn get_the_post_thumbnail_url( $download_id, 'full' ) ?: '';\n\t\t\t}\n\t\t],\n\t\t'download_files_count' =\u003e [\n\t\t\t'label'    =\u003e 'Number of Files',\n\t\t\t'callback' =\u003e function ( $download_id ) {\n\t\t\t\t$files = edd_get_download_files( $download_id );\n\n\t\t\t\treturn count( $files );\n\t\t\t}\n\t\t],\n\t\t'total_earnings'       =\u003e [\n\t\t\t'label'    =\u003e 'Total Earnings',\n\t\t\t'callback' =\u003e function ( $download_id ) {\n\t\t\t\treturn edd_get_download_earnings_stats( $download_id );\n\t\t\t}\n\t\t],\n\t\t'total_sales'          =\u003e [\n\t\t\t'label'    =\u003e 'Total Sales',\n\t\t\t'callback' =\u003e function ( $download_id ) {\n\t\t\t\treturn edd_get_download_sales_stats( $download_id );\n\t\t\t}\n\t\t]\n\t];\n\n\tedd_register_export_columns( 'downloads', $download_columns );\n}\n\nadd_action( 'init', 'add_export_columns' );\n```\n\n## Parameters\n\n| Parameter | Type | Required | Description |\n|-----------|------|----------|-------------|\n| `$type` | string | **Yes** | Export type ('customers', 'downloads', 'payments', etc.) |\n| `$columns` | array | **Yes** | Array of column configurations |\n| `$id_field` | string | No | ID field name (default: 'ID') |\n| `$error_callback` | callable | No | Error handling function |\n\n### Column Configuration\n\n| Option | Required | Description |\n|--------|----------|-------------|\n| `label` | **Yes** | Column header text |\n| `callback` | **Yes** | Function that returns column value |\n\n## Export Types\n\nCommon EDD export types you can extend:\n\n- `customers` - Customer export data\n- `downloads` - Download/product export data\n- `payments` - Payment/order export data\n- `file_downloads` - File download logs\n- `customers_export` - Alternative customer export\n\n## Requirements\n\n- PHP 7.4+\n- WordPress 5.0+\n- Easy Digital Downloads 3.0+\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the GPL-2.0-or-later License.\n\n## Support\n\n- [Documentation](https://github.com/arraypress/edd-register-export-columns)\n- [Issue Tracker](https://github.com/arraypress/edd-register-export-columns/issues)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farraypress%2Fedd-register-export-columns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farraypress%2Fedd-register-export-columns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farraypress%2Fedd-register-export-columns/lists"}