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', 10, 2 );
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_formula_computer_variables
This filter is used to customize the set of variables made available to formula-based rates.
Parameters
– $variables
array
the current set of variables
– $rate
Affiliates_Rate
the rate applied for which variables are supplied
– $context
array
information related to the context within which the rate is used to calculate the commission
Returns
– array
variables
Example:
Imagine that you wanted to provide an additional variable c which you can then use in your formula-based rates. Here we will just assign the value 10 to the variable, but you could do any complex evaluation and add as many variables as needed.
function my_variables( $variables, $rate, $context ) { $variables['c'] = 10; return $variables; } add_filter( 'affiliates_formula_computer_variables', 'my_variables', 10, 3 );
The above filter function can be placed in your active child theme’s functions.php or better create your own little plugin.
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_notifications_tokens
This filter should return the values for the tokens used in affiliate notification emails, used to notify the site admin and the referring affiliate when a referral has been granted. This filter can be used to modify and add tokens.
Parameters
– $tokens
array of string indexed by token keys
The following tokens are provided, additional tokens can be added by returning an enhanced array.
– site_title
: The title of the site.
– site_url
: The URL of the site.
– affiliate_name
: The name of the affiliate being notified.
– affiliate_id
: The ID of the affiliate being notified.
– affiliate_email
: The email address of the affiliate being notified.
– referral_status
: The current status of the referral.
– referral_id
: The ID of the referral causing the notification.
Returns
– array of string with token key-value pairs
affiliates_notifications_data_tokens
This filter should return an array of data token keys that are recognized when the site admin and the referring affiliate is notified of a referral.
Parameters
– $data_tokens
array integration-specific data token keys to be made available as tokens that can be used in the notification
– $tokens
array available tokens, key-value pairs of general notification tokens
Returns
– array of data tokens
affiliates_notifications_data
This filter should return an array of data token values available for substitution when the site admin and the referring affiliate is notified of a referral.
Parameters
– $data
array of integration-specific data key-value pairs
– $data_tokens
array of string, recognized data keys
– $tokens
array general available tokens
Returns
– array of data key-value pairs
affiliates_coupons_equality_test
This filter should return true if two coupons are deemed equal or false otherwise.
Parameters
– $test
boolean true if the coupons are currently deemed equal
– $coupon1
string coupon code
– $coupon2
string coupon code
Returns
– boolean true if $coupon1
and $coupon2
are deemed equal
affiliates_coupon_affiliate_id
This filter should return the ID of the affiliate recognized for a coupon.
Parameters
– $affiliate_id
int recognized affiliate ID
– $coupon
string coupon code
Returns
– int affiliate ID or null
affiliates_record_referral
This filter should return true if a referral should be recorded based on the provided referral data.
Parameters
– $value
boolean whether the referral should be recorded
– $referral_data
array of referral data
Returns
– boolean true if the referral should be recorded
affiliates_tiers_output
This filter is used to modify the output of the [affiliates_tiers]
shortcode.
Parameters
– $output
string
Returns
– string tiers output
affiliates_process_tiers_referral
The return value of this filter determines whether tiers will be processed for a referral. When a new referral is recording a commission for an affiliate and tiers are enabled, this filter shall return true if the system should also record referrals for the downline of the referring affiliate. If this filter returns true, tiers in the downline of the affiliate to which the referral identified by $referral_id has been granted will also be granted referrals for the related transaction if appropriate. The filter can be used to avoid recording tier referrals under certain conditions or to implement a replacement method for processing tiers.
The global $affiliates_enterprise_doing_tiers
is only set to true
after this filter has been evaluated and returned true
. The value of this global can be used to ascertain whether a referral being recorded is related to tier processing (i.e. referrals being recorded for additional commissions in the downline of an affiliate) or a normal referral is directly recorded for a transaction.
Parameters
– $process
boolean whether to process tiers for the referral
– $referral_id
int the ID of the referral for which to process tiers
– $params
array the parameters passed to the add_referrals method
Returns
– boolean true if tier referrals for the transaction of the referral should be processed, false otherwise
affiliates_process_tiers_referral_type
The return value of this filter determines whether tiers will be processed for a referral, the referral type and details are provided as parameters when the filter is invoked. This filter is invoked after the affiliates_process_tiers_referral
and can be used to make the decision based on further details, especially the referral type and its parameteres. This filter will only be invoked if the affiliates_process_tiers_referral
allowed further processing.
The global $affiliates_enterprise_doing_tiers
will have the value true
when this filter is being evaluated as the filter is invoked while tier referrals are processed.
This filter can be used to implement an alternative handler to process tier referrals or to decide whether tier referrals should be recorded for the individual referral identified by $referral_id
.
Parameters
– $process
boolean whether to process tiers for the referral
– $referral_type
string the type of the referral for which to process tiers
– $params
array the parameters passed to the add_referrals method
– $referral
object the row object from the referrals table for the referral identified by $referral_id
Returns
– boolean true if tier referrals for the transaction of the referral should be processed, false otherwise
affiliates_cookie_timeout_days
This filter should return the expiration of the affiliate cookie in days.
Parameters
–
int the number of days used for cookie expiration$
days
–
int the affiliate ID$
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
affiliates_affiliate_stats_renderer_data
Allows to modify or extend the stored data set displayed for a referral. See Affiliates Stats Filters Example for an example usage of this filter. This filter is available from Affiliates Pro version 2.14.1 and Affiliates Enterprise version 2.14.1.
Parameters
– $data
array data set for the referral
– $result
object the current referral row
Returns
– array data set for the referral
affiliates_affiliate_stats_renderer_data_output
Allows to modify the output of the Details column displayed for a referral. See Affiliates Stats Filters Example for an example usage of this filter. This filter is available from Affiliates Pro version 2.14.1 and Affiliates Enterprise version 2.14.1.
Parameters
– $output
string current output for the details column of the referral
– $result
object row object for the current referral
Returns
– string output for the details column of the referral
affiliates_affiliate_stats_renderer_column_display_names
Allows to modify and reorder the columns used to display referrals. See Affiliates Stats Filters Example for an example usage of this filter. This filter is available from Affiliates Pro version 2.14.1 and Affiliates Enterprise version 2.14.1.
Parameters
– $column_display_names
array maps keys to column display names
Returns
– array of keys mapped to column display names
affiliates_affiliate_stats_renderer_column_output
This filter is used to create the output for additional columns added via the affiliates_affiliate_stats_renderer_column_display_names
filter. See Affiliates Stats Filters Example for an example usage of this filter. This filter is available from Affiliates Pro version 2.14.1 and Affiliates Enterprise version 2.14.1.
Parameters
– $output
string
– $key
string the column key
– $result
object row object for the current referral
Returns
– string output for the column identified by key and the current row object
affiliates_banner_before
Allows to prepend HTML before the banner container div with class affiliates-banner.
Parameters
– $output
string current HTML prepended, defaults to the empty string
– $atts
array banner shortcode attributes
Returns
– string HTML to be prepended
affiliates_banner_after
Allows to append HTML after the banner container div with class affiliates-banner.
Parameters
– $output
string current HTML appended, defaults to the empty string
– $atts
array banner shortcode attributes
Returns
– string HTML to be appended
affiliates_banner_image_before
Allows to prepend HTML before the banner image container div with class banner-image.
Parameters
– $output
string current HTML prepended, defaults to the empty string
– $id
int identifies the banner image
– $url
string identifies the banner URL
– $atts
array banner shortcode attributes
Returns
– string HTML to be prepended
affiliates_banner_image_after
Allows to append HTML after the banner image container div with class banner-image.
Parameters
– $output
string current HTML appended, defaults to the empty string
– $id
int identifies the banner image
– $url
string identifies the banner URL
– $atts
array banner shortcode attributes
Returns
– string HTML to be appended
affiliates_banner_code_before
Allows to prepend HTML before the banner code container div with class banner-code.
Parameters
– $output
string current HTML prepended, defaults to the empty string
– $id
int identifies the banner image
– $url
string identifies the banner URL
– $atts
array banner shortcode attributes
Returns
– string HTML to be prepended
affiliates_banner_code_after
Allows to append HTML after the banner code container div with class banner-code.
Parameters
– $output
string current HTML appended, defaults to the empty string
– $id
int identifies the banner image
– $url
string identifies the banner URL
– $atts
array banner shortcode attributes
Returns
– string HTML to be appended
affiliates_banner
Allows to modify the output for banners.
Parameters
– $output
string the current HTML
– $atts
array banner shortcode attributes
Returns
– string HTML
affiliates_banner_empty_subdir
Parameters
– $empty
boolean defaults to true
Returns
– boolean
affiliates_totals_payment_file_line
When generating a mass payment file, allows to modify the line data before it is output.
Parameters
– $line
array current line data
– $affiliate_id
int current affiliate ID
– $user_id
int current affiliate’s user ID
– $result
raw object data for the current line
Returns
– array line data
affiliates_totals_payment_file_line_output
When generating a mass payment file, allows to modify the output of a line in the file.
Parameters
– $output
string line output
– $line
array current line data
– $affiliate_id
int current affiliate ID
– $user_id
int current affiliate’s user ID
– $result
raw object data for the current line
Returns
– string line output
affiliates_totals_export_file_headings
When generating a totals export file, allows to modify the headings (first line).
Parameters
– $headings
array
Returns
– array headings
affiliates_totals_export_file_line
When generating a totals export file, allows to modify the line data before it is output.
Parameters
– $line
array current line data
– $affiliate_id
int current affiliate ID
– $user_id
int current affiliate’s user ID
– $result
raw object data for the current line
Returns
– array line data
affiliates_totals_export_file_line_output
When generating a totals export file, allows to modify the output of a line in the file.
Parameters
– $output
string line output
– $line
array current line data
– $affiliate_id
int current affiliate ID
– $user_id
int current affiliate’s user ID
– $result
raw object data for the current line
Returns
– string line output