Primary

Filters

Filter reference for the Affiliate, Affiliates Pro and Affiliates Enterprise plugins.

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

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

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

Before you modify your functions.php and the database with the following query, 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.

The following example function can be used to modify the number of decimals used for referral amounts. You can put this in your functions.php:

function affiliates_change_decimals_example( $decimals ) {
    return 5; // 5 decimals instead of 2 used by default
}
add_filter( 'affiliates_referral_amount_decimals', 'affiliates_change_decimals_example' );

You must also change the database type of the column ‘amount’ in the ‘wp_aff_referrals’ table (here using the default ‘wp’ as prefix in the WordPress database tables).

To modify the column ‘amount’ from MySQL use the query:

ALTER TABLE wp_aff_referrals MODIFY amount DECIMAL (18,5);

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_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 the User Registration integration.

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