arraypress / edd-register-customer-stats
A library for registering custom customer statistics in Easy Digital Downloads admin area
Package info
github.com/arraypress/edd-register-customer-stats
pkg:composer/arraypress/edd-register-customer-stats
dev-main
2026-08-23 14:39 UTC
Requires
- php: >=8.3
This package is auto-updated.
Last update: 2026-08-23 15:05:20 UTC
README
Add custom statistics to Easy Digital Downloads customer profiles in the admin area.
Installation
composer require arraypress/edd-register-customer-stats
Basic Usage
// Single stat edd_register_customer_stat( 'support_tickets', [ 'singular' => 'Support Ticket', 'plural' => 'Support Tickets', 'callback' => function ( $customer ) { return get_user_meta( $customer->user_id, 'support_ticket_count', true ) ?: 0; }, 'icon' => 'dashicons-sos', 'url' => admin_url( 'admin.php?page=support&customer=' ), 'priority' => 10 ] ); // Multiple stats edd_register_customer_stats( [ 'forum_posts' => [ 'singular' => 'Forum Post', 'plural' => 'Forum Posts', 'callback' => function ( $customer ) { return count_user_posts( $customer->user_id, 'forum_post' ); }, 'icon' => 'dashicons-format-chat' ], 'last_login' => [ 'singular' => 'Last Login', 'plural' => 'Last Logins', 'callback' => function ( $customer ) { $last_login = get_user_meta( $customer->user_id, 'last_login', true ); return $last_login ? human_time_diff( $last_login ) . ' ago' : 'Never'; }, 'icon' => 'dashicons-clock' ], 'downloads' => [ 'singular' => 'Download', 'plural' => 'Downloads', 'callback' => function ( $customer ) { return edd_count_file_downloads_of_customer( $customer->id ); }, 'icon' => 'dashicons-download', 'url' => admin_url( 'edit.php?post_type=download&page=edd-reports&view=file_downloads&customer=' ) ] ] );
Configuration Options
| Option | Required | Description |
|---|---|---|
singular |
Yes | Singular label (e.g., "Download") |
plural |
Yes | Plural label (e.g., "Downloads") |
callback |
Yes | Function that returns the stat value |
icon |
No | Dashicons class (default: dashicons-info) |
url |
No | Base URL for clickable stats |
priority |
No | Display order (default: 10) |
span_class |
No | Additional CSS class |
Real Examples
function add_customer_stats() { $stats = []; // WooCommerce orders (if both plugins active) if ( class_exists( 'WooCommerce' ) ) { $stats['woo_orders'] = [ 'singular' => 'WooCommerce Order', 'plural' => 'WooCommerce Orders', 'callback' => function ( $customer ) { return $customer->user_id ? wc_get_customer_order_count( $customer->user_id ) : 0; }, 'icon' => 'dashicons-store' ]; } // Affiliate referrals if ( function_exists( 'affiliate_wp' ) ) { $stats['referrals'] = [ 'singular' => 'Referral', 'plural' => 'Referrals', 'callback' => function ( $customer ) { $affiliate_id = affwp_get_affiliate_id( $customer->user_id ); return $affiliate_id ? affiliate_wp()->referrals->count( [ 'affiliate_id' => $affiliate_id ] ) : 0; }, 'icon' => 'dashicons-share', 'url' => admin_url( 'admin.php?page=affiliate-wp-referrals&affiliate=' ) ]; } // Subscription count if ( class_exists( 'EDD_Recurring' ) ) { $stats['subscriptions'] = [ 'singular' => 'Active Subscription', 'plural' => 'Active Subscriptions', 'callback' => function ( $customer ) { return count( EDD_Recurring()->db->get_subscriptions( [ 'customer_id' => $customer->id, 'status' => 'active' ] ) ); }, 'icon' => 'dashicons-update' ]; } if ( ! empty( $stats ) ) { edd_register_customer_stats( $stats ); } } add_action( 'init', 'add_customer_stats' );
Requirements
- PHP 7.4+
- WordPress 5.0+
- Easy Digital Downloads 3.0+
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the GPL-2.0-or-later License.