Customize the My Account tab

Refer a Friend adds a Refer a Friend tab to My Account, just above Log out. Its address is /my-account/myreferrals/. This page shows how to rename it, remove it, or fix it in themes that display it incorrectly.

Before you start: read Add code snippets safely. All snippets are checked with version 4.4.12.

Rename the tab

add_filter( 'gens_raf_tab_title', function () {
    return 'Invite friends';
} );

This also renames the Refer a Friend tab on product pages. If your site is multilingual, translate the “Refer a Friend” string with a translation plugin such as Loco Translate or WPML instead.

Remove the tab

Use this if you show the referral section somewhere else, for example on a page with the [WOO_GENS_RAF_FULL] shortcode.

add_action( 'wp', function () {
    if ( ! class_exists( 'WPGens_RAF' ) ) {
        return;
    }
    remove_filter( 'woocommerce_account_menu_items', array( WPGens_RAF::instance()->my_account, 'gens_account_menu_item' ), 10 );
} );

The tab disappears from the menu. The /my-account/myreferrals/ address still works if someone has it bookmarked.

Fix an empty button in the account menu

Some themes, such as Flatsome, build the account menu their own way. The plugin moves Log out to stay last, and in those themes an empty button can appear. This snippet adds the tab without moving Log out:

add_action( 'wp', function () {
    if ( ! class_exists( 'WPGens_RAF' ) ) {
        return;
    }
    remove_filter( 'woocommerce_account_menu_items', array( WPGens_RAF::instance()->my_account, 'gens_account_menu_item' ), 10 );
    add_filter( 'woocommerce_account_menu_items', function ( $items ) {
        $items['myreferrals'] = apply_filters( 'gens_raf_tab_title', __( 'Refer a Friend', 'gens-raf' ) );
        return $items;
    }, 10 );
} );

The tab shows a “page not found” error

The tab uses a WooCommerce account endpoint. After installing or updating the plugin, go to Settings → Permalinks and click Save Changes once. This refreshes WordPress’s addresses.

Check it worked

Log in as a customer and open My Account. The tab should have the new name, be gone, or show without an empty button, depending on the snippet.

Related

Browse our plugins

Lightweight WooCommerce plugins built for speed. No bloat, no frameworks -- just clean code that works.

View all plugins
Stay in the loop

Get notified when we launch new plugins. No spam, just product updates.