Use code NOVASHARE for an extra 10% off!
  1. Home
  2. Docs
  3. General
  4. How to add the integration with AffiliateWP

How to add the integration with AffiliateWP

AffiliateWP is an amazing platform and service for WordPress business owners to easily add an affiliate program to their website. We use AffiliateWP on all of our ecommerce sites.

You can use the novashare_permalink filter below to add an integration with AffiliateWP. If your customer (who is also an affiliate) is logged in, and they share a link from your site using Novashare, it will automatically append their affiliate ID to the URL.

If you need an easy way to add a filter, we recommend the free WPCode plugin.

add_filter('novashare_permalink', function($link, $network) {

    //make sure affiliate wp is available
    if(function_exists('affwp_is_affiliate')) {

        //check that user is affiliate
        if(is_user_logged_in() && affwp_is_affiliate()) {

            //add query arg to link
            $link = add_query_arg(affiliate_wp()->tracking->get_referral_var(), affwp_get_affiliate_id(), $link);
        }
    }

    return $link;
}, 10, 2);

The one caveat with the integration is that it doesn’t support Bitly short links.

Before

Here is an example of a URL before adding the integration.

https://novashare.io/

After

Here is an example of a URL after adding the integration. The affiliate ID of the logged-in user is automatically appended to the URL when they share using Novashare.

https://novashare.io/?ref=5
Was this article helpful?

Related Articles