# Show "Become an Affiliate" or "Affiliate Area" Menu Link (AffiliateWP)

> Adds a menu item to a theme menu location that reads "Affiliate Area" for affiliates and "Become an affiliate" for everyone else, both pointing to your AffiliateWP page.

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

## Code

```php
$wpide_location = 'primary'; // Theme menu location.

add_filter( 'wp_nav_menu_items', function ( $items, $args ) use ( $wpide_location ) {
    if ( ! function_exists( 'affiliate_wp' ) || empty( $args->theme_location ) || $args->theme_location !== $wpide_location ) {
        return $items;
    }

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

    if ( ! $page_id ) {
        return $items;
    }

    $is_affiliate = is_user_logged_in() && affwp_get_affiliate_id( get_current_user_id() );
    $label        = $is_affiliate ? __( 'Affiliate Area' ) : __( 'Become an affiliate' );

    return $items . sprintf( '<li class="menu-item menu-item-affiliate"><a href="%1$s">%2$s</a></li>', esc_url( get_permalink( $page_id ) ), esc_html( $label ) );
}, 10, 2 );
```

## Notes

Set $wpide_location to your theme's menu location.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Show "Become an Affiliate" or "Affiliate Area" Menu Link (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/
