Primary

Filters

affiliates_currencies

This filter allows to modify the currencies known to the system.

Parameters

$currencies array an associative array that maps currency symbols to currency names

Return

array maps currency symbols to currency names

affiliates_dashboard_setup_sections

This filter provides the sections used to compose the dashboard for the current context. Section keys are mapped to the class used to create the section and the parameters passed to create the section object. The filter can thus be used to alter the sections that are rendered, add or remove sections and establish a different order.

Parameters

$sections array sections for the current context
$dashboard Affiliates_Dashboard the dashboard object

Returns

array sections for the current context

affiliates_affiliate_area_page_content

This filter should return the desired page content for the generated default affiliate area.

Parameters

$affiliate_area_page_content string HTML page content for the default affiliate area

Returns

– string HTML page content

affiliates_setup_pages

This filter should return the IDs of generated pages.

Parameters

$post_ids array of int holding the IDs of the pages that have been generated

Returns

– array of int holding page IDs

affiliates_registration_error_validate

This filter should return true if there are validation errors for the fields of the submitted affiliate registration form.

Parameters

$error boolean current validation result

Returns

– boolean validation result

login_errors

This filter is applied to the login error message printed on the login screen. This WordPress filter is invoked when there are errors on the affiliate registration form. See login_errors.

Parameters

$errors array of string with error messages

Returns

– array of string with error messages

login_messages

This filter is applied to the login message printed on the login screen. This WordPress filter is invoked when there are messages on the affiliate registration form. See login_message.

Parameters

$messages array of string with messages

Returns

– array of string with messages

affiliates_registration_profile_url

This filter can be used to modify the profile URL that is indicated to registered users, when they are asked to fill in missing information that is required to sign them up as affiliates.

Parameters

$url string the profile URL (defaults to the one return by admin_url( "profile.php" ))

Returns

– string desired URL

affiliates_registration_before_fields

This filter is used to render markup within the affiliate registration form, before the default fields are displayed.

Parameters

$output string defaults to the empty string

Returns

– string desired output before the form fields

affiliates_registration_after_fields

This filter is used to render markup within the affiliate registration form, after the default fields are displayed.

Parameters

$output string defaults to the empty string

Returns

– string desired output after the form fields

affiliates_admin_email

This filter should be used to provide the administrator email address to which affiliate notifications are sent.

Parameters

$admin_email string admin email address

Returns

string admin email address

affiliates_new_affiliate_registration_subject

This filter should return the email subject for notifications when a new affiliate has been registered.

Parameters

$subject string
$params array

Returns

– string email subject

affiliates_new_affiliate_registration_message

This filter should return the email body for notifications when a new affiliate has been registered.

Parameters

$message string
$params array

Returns

– string email message

affiliates_new_affiliate_registration_headers

This filter is used to add headers for the registration notification message.

Parameters

– $message string
– $params array

Returns

– string headers

affiliates_service_affiliate_id

This filter should return the referring affiliate’s ID.

Parameters

$affiliate_id int the ID of the referring affiliate
$service string the service used to recognize the referring affiliate

Returns

– int the ID of the referring affiliate or null

affiliates_earnings_display_currency

This filter should return the desired output for the currency.

Parameters

$currency_id string The three-letter currency code.

Returns

– string The desired representation.

affiliates_earnings_display_total

This filter can be used to modify the total displayed for an entry in the earnings table.

Parameters

$formatted_total string
$total string
$currency_id string

Returns

– string the formatted total

affiliates_earnings_decimals

To return the number of desired decimals when displaying an earnings total in the table.

Parameters

$decimals int defaults to 2

Returns

– int number of desired decimals

affiliates_referral_amount_decimals

The default precision used to handle referral amounts is 2 decimals. If you want to use a higher precision, for example to use 4 decimals in referral amount calculations instead of 2, add the following line to your wp-config.php:

define( 'AFFILIATES_REFERRAL_AMOUNT_DECIMALS', 4 );

A second constant can be used to modify the decimals used for display, for example:

define( 'AFFILIATES_REFERRAL_AMOUNT_DECIMALS_DISPLAY', 4 );

The maximum allowed precision is up to 6 decimals. The default used for both constant is 2 decimals.

The affiliates_referral_amount_decimals filter can be used to further modify these values dynamically, but we recommend to set the constants in wp-config.php. The filter will override the constants.

The filter receives two parameters, first the decimals to be used (default is 2) and second the context (which will be either the empty string '' or 'display'). The filter must return the decimals to be used.

The following example function illustrates the case where 6 decimals are used for calculations and 2 for display. Again, it’s better to just define the constants in your wp-config.php, but you can put this in your functions.php:

function affiliates_change_decimals_example( $decimals, $context ) {
    if ( $context === 'display' ) {
        $decimals = 2;
    } else {
        $decimals = 6;
    }
    return $decimals;
}
add_filter(
    'affiliates_referral_amount_decimals',
    'affiliates_change_decimals_example'
);

Before you modify your wp-config.php or your functions.php, make sure to make a full backup of your site and database. You should also test this on a staging site before using it on your production site.

affiliates_earnings_display_total_no_earnings

Can be used to modify the message that is displayed when no earnings can be shown in the table yet due to lack of referrals.

Parameters

$message string the message – defaults to ‘There are no earnings yet.’

Returns

– string the desired message

affiliates_captcha_get

This filter should return the markup for a CAPTCHA field. This field is used for affiliate registration purposes.

Parameters

$field string CAPTCHA markup
$value string the value of the CAPTCHA field

Returns

– string markup

affiliates_captcha_validate

This filter should return true if the CAPTCHA field used for affiliate registration purposes passes validation.

Parameters

$result boolean validation result, true if CAPTCHA validates
$field_value string the user-submitted value for the CAPTCHA field

affiliates_parse_request_affiliate_id

This filter should return the ID of the affiliate identified as the referring affiliate, based on the query variables of the request. A cookie identifying the referring affiliate will be placed if the affiliate ID is valid.

Parameters

$value string the value of the request parameter supposed to identify the affiliate
$affiliate_id int the ID of the affiliate that has been recognized as the referring affiliate

Returns

– int affiliate ID

affiliates_redirect_status_code

When redirection is enabled, this filter can be used to change the redirection status code. The default is 302. This applies to affiliate URLs which are redirected after being recognized.

Parameters

$status int the redirect status code (default 302)

Returns

– int desired redirect status code (only codes from 300 to 307 are allowed)

affiliates_record_referral

This filter should return true if a referral should be recorded based on the provided referral data.

Parameters

$result boolean whether a referral should be recorded
$referral_data array pertaining referral data

Returns

– boolean true if a referral should be recorded

affiliates_record_robot_hits

This filter returns false by default (as determined by the value of the AFFILIATES_RECORD_ROBOT_HITS constant). It determines whether a hit on an affiliate link that is identified as coming from an robot is recorded or not. We recommend to keep this at its default.

Parameters

$record boolean whether to record the hit

Returns

boolean false if the hit should not be recorded

affiliates_is_duplicate_referral

This filter should return true if a referral that is about to be recorded, would duplicate an existing referral.

Parameters

$is_duplicate boolean true if the potential referral is considered a duplicate
$atts array pertaining referral data

Returns

– boolean true if a duplicate is recognized

affiliates_add_submenu_page_function

This filter should return the function used to render the content for a submenu item in the Affiliates menu.

Parameters

$function_name string name of the function

Returns

– string name of the function

affiliates_footer

Filter used to render the footer.

Parameters

$footer string markup

Returns

– string markup

affiliates_supported_currencies

Used to modify the supported currencies used in some integrations.

Parameters

$currencies array of string holding currency IDs (e.g. USD, EUR, …)

Returns

– array of string

affiliates_cookie_timeout_days

This filter should return the expiration of the affiliate cookie in days.

Parameters

– $days int the number of days used for cookie expiration

– $affiliate_id int the affiliate ID

Returns

– int number of days

affiliates_updated_affiliate_status_params

This filter applies when an affiliate is notified of an update to his status. The filter receives and must return an array $params with relevant data used in the notification indexed by the following keys:

  • user_id
  • user
  • username
  • site_login_url
  • blogname

Parameters

– $params array notification parameters

Returns

– array of parameters

affiliates_new_affiliate_registration_params

This filter applies when the blog administrator is notified of a new affiliate. The filter receives and must return an array $params with relevant data used in the notification indexed by the following keys:

  • user_id
  • user
  • username
  • site_login_url
  • blogname

Parameters

– $params array notification parameters

Returns

– array of parameters

affiliates_new_affiliate_user_registration_params

This filter applies when a new affiliate is notified of his user account. The filter receives and must return an array $params with relevant data used in the notification indexed by the following keys:

  • user_id
  • user
  • username
  • password
  • site_login_url
  • blogname

Parameters

– $params array notification parameters

Returns

– array of parameters

affiliates_new_affiliate_user_registration_subject

This filter applies when a new affiliate is notified of his user account. The filter receives and must return the subject line of the notification.

Parameters

$subject string notification subject
$params array notification parameters

Returns

– string notification subject

affiliates_new_affiliate_user_registration_message

This filter applies when a new affiliate is notified of his user account. The filter receives and must return the message of the notification.

Parameters

$message string notification message
$params array notification parameters

Returns

– string notification message

affiliates_new_affiliate_user_registration_headers

This filter applies when a new affiliate is notified of his user account. The filter receives and must return the additional headers used for the notification.

Parameters

$headers string notification headers
$params array notification parameters

Returns

– string notification headers