slicewp_get_affiliate_url()

Description

Returns the affiliate’s referral link.

Parameters

slicewp_get_affiliate_url( $affiliate_id, $url = '' );
  • $affiliate_id (int)(required) – The affiliate’s ID.
  • $url (string)(optional) – A URL that replaces the base URL on which the referral URL is built upon. Defaults to empty string.

Return

(string|null) The affiliate’s referral URL, or null if there’s no affiliate associated with the provided $affiliate_id or if the affiliate’s status is different than active.

More information

The URL that is returned when this function is called without the $url parameter is built from a base URL on top of which the plugin adds the affiliate query argument.

The base URL defaults to the value returned by WordPress’ site_url() function and can be modified using the slicewp_affiliate_url_base filter.

Example

Get the affiliate’s default referral link

$referal_link = slicewp_get_affiliate_url( 10 );
// Returned value.

https://yourwebsite.com/?aff=10

Get the affiliate referral link for a particular URL

$referal_link = slicewp_get_affiliate_url( 10, 'https://yourwebsite.com/products/product-1/' );
// Returned value.

https://yourwebsite.com/products/product-1/?aff=10

Was this article helpful?

Do you have any feedback or suggestions to improve this page?

Can't find what you're looking for? We're here to help.

Contact us