# Dashboard Widget: Pending Referrals (AffiliateWP)

> Adds a dashboard widget for administrators with the number and value of referrals waiting for review, plus pending affiliate applications, linking to each AffiliateWP screen.

- Type: PHP
- Runs: Admin only
- Category: [Plugin Integrations](https://wpide.com/library/category/integrations/)
- Tags: affiliatewp, dashboard, referrals
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/affwp-pending-referrals-widget/

## Code

```php
add_action( 'wp_dashboard_setup', function () {
    if ( ! function_exists( 'affiliate_wp' ) || ! current_user_can( 'manage_referrals' ) ) {
        return;
    }

    wp_add_dashboard_widget( 'wpide_affwp_pending', __( 'Affiliate program' ), function () {
        $data = get_transient( 'wpide_affwp_pending' );

        if ( false === $data ) {
            $data = array(
                'referrals'  => (int) affiliate_wp()->referrals->count( array( 'status' => 'pending' ) ),
                'affiliates' => (int) affiliate_wp()->affiliates->count( array( 'status' => 'pending' ) ),
            );
            set_transient( 'wpide_affwp_pending', $data, 10 * MINUTE_IN_SECONDS );
        }

        printf(
            '<p><a href="%1$s"><strong>%2$s</strong> %3$s</a></p><p><a href="%4$s"><strong>%5$s</strong> %6$s</a></p>',
            esc_url( admin_url( 'admin.php?page=affiliate-wp-referrals&status=pending' ) ),
            esc_html( number_format_i18n( $data['referrals'] ) ),
            esc_html__( 'referrals pending review' ),
            esc_url( admin_url( 'admin.php?page=affiliate-wp-affiliates&status=pending' ) ),
            esc_html( number_format_i18n( $data['affiliates'] ) ),
            esc_html__( 'affiliate applications waiting' )
        );
    } );
} );
```

## Notes

Counts are cached for ten minutes.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Dashboard Widget: Pending Referrals (AffiliateWP)" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
