# Affiliate Area Link in the Admin Bar (AffiliateWP)

> Adds an "Affiliate Area" link to the toolbar for logged-in affiliates, showing their unpaid earnings, so they can reach their dashboard from anywhere on the site.

- Type: PHP
- Runs: Run everywhere
- Category: [Plugin Integrations](https://wpide.com/library/category/integrations/)
- Tags: affiliatewp, admin-bar, affiliates
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/affwp-admin-bar-affiliate-area/

## Code

```php
add_action( 'admin_bar_menu', function ( $bar ) {
    if ( ! function_exists( 'affwp_get_affiliate_id' ) || ! is_user_logged_in() ) {
        return;
    }

    $affiliate_id = affwp_get_affiliate_id( get_current_user_id() );
    $page_id      = (int) affiliate_wp()->settings->get( 'affiliates_page' );

    if ( ! $affiliate_id || ! $page_id ) {
        return;
    }

    $bar->add_node( array(
        'id'    => 'wpide-affiliate-area',
        'title' => esc_html( sprintf( 'Affiliate Area (%s)', wp_strip_all_tags( affwp_get_affiliate_unpaid_earnings( $affiliate_id, true ) ) ) ),
        'href'  => get_permalink( $page_id ),
    ) );
}, 85 );
```

## Notes

Uses the Affiliate Area page set in AffiliateWP > Settings.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Affiliate Area Link in the Admin Bar (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/
