Below, you’ll find a detailed guide on how to add the Affiliatewp Affiliate Area Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Affiliatewp Affiliate Area Shortcodes Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the Affiliatewp Affiliate Area Shortcodes Plugin and the shortcodes it provides:
"WordPress Affiliate Program Plugin Shortcodes by AffiliateWP is an efficient tool that provides handy shortcodes for creating a custom affiliate area. It streamlines affiliate marketing on your WordPress site."
- [affiliate_area_graphs]
- [affiliate_area_settings]
- [affiliate_area_creatives]
- [affiliate_area_referrals]
- [affiliate_area_stats]
- [affiliate_area_urls]
- [affiliate_area_payouts]
- [affiliate_area_visits]
- [affiliate_referrals]
- [affiliate_earnings]
- [affiliate_visits]
- [affiliate_conversion_rate]
- [affiliate_commission_rate]
- [affiliate_campaign_stats]
- [affiliate_id]
- [affiliate_username]
- [affiliate_name]
- [affiliate_website]
- [affiliate_area_notices]
- [affiliate_logout]
Affiliatewp Affiliate Area [affiliate_area_graphs] Shortcode
The AffiliateWP-Affiliate-Area-Shortcodes plugin shortcode ‘affiliate_area_graphs’ generates a graphical representation of an affiliate’s progress. It checks if the user is an active affiliate and displays the graphs in the affiliate dashboard. .
Shortcode: [affiliate_area_graphs]
Examples and Usage
Basic example – Displays the affiliate dashboard with graphs for an active affiliate
[affiliate_area_graphs /]
Advanced examples
Using the shortcode to display the affiliate dashboard with graphs for an active affiliate, and wrapping it with custom HTML for styling or additional information.
<div class="my-affiliate-dashboard">
[affiliate_area_graphs /]
</div>
Embedding the shortcode within a page’s content, allowing you to provide additional context or information around it.
<p>Check out your performance below:</p>
[affiliate_area_graphs /]
<p>Keep up the good work!</p>
Note that the ‘affiliate_area_graphs’ shortcode does not accept any parameters or attributes, as it’s designed to simply display the affiliate dashboard with graphs for the currently logged-in and active affiliate. Any customization or additional functionality would need to be implemented through additional code or plugins.
PHP Function Code
In case you have difficulties debugging what causing issues with [affiliate_area_graphs]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'affiliate_area_graphs', array( $this, 'affiliate_area_graphs' ) );
Shortcode PHP function:
function affiliate_area_graphs( $atts, $content = null ) {
if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) {
return;
}
ob_start();
echo '<div id="affwp-affiliate-dashboard">';
affiliate_wp()->templates->get_template_part( 'dashboard-tab', 'graphs' );
echo '</div>';
$content = ob_get_clean();
return do_shortcode( $content );
}
Code file location:
affiliatewp-affiliate-area-shortcodes/affiliatewp-affiliate-area-shortcodes/includes/class-shortcodes.php
Affiliatewp Affiliate Area
[affiliate_area_settings] Shortcode
The AffiliateWP-Affiliate-Area-Shortcodes plugin shortcode, ‘affiliate_area_settings’, is designed to add a settings section in the affiliate dashboard. It checks if the user is an active affiliate before rendering the settings tab.
Shortcode: [affiliate_area_settings]
Examples and Usage
Basic example – The shortcode ‘affiliate_area_settings’ is used to display the settings tab in the affiliate dashboard. It checks if the user is an affiliate and if the affiliate is active. If both conditions are met, the settings tab is displayed.
[affiliate_area_settings /]
PHP Function Code
In case you have difficulties debugging what causing issues with [affiliate_area_settings]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'affiliate_area_settings', array( $this, 'affiliate_area_settings' ) );
Shortcode PHP function:
function affiliate_area_settings( $atts, $content = null ) {
if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) {
return;
}
ob_start();
echo '<div id="affwp-affiliate-dashboard">';
affiliate_wp()->templates->get_template_part( 'dashboard-tab', 'settings' );
echo '</div>';
$content = ob_get_clean();
return do_shortcode( $content );
}
Code file location:
affiliatewp-affiliate-area-shortcodes/affiliatewp-affiliate-area-shortcodes/includes/class-shortcodes.php
Affiliatewp Affiliate Area Shortcodes [affiliate_area_creatives] Shortcode
The AffiliateWP-Affiliate-Area-Shortcodes plugin’s shortcode, ‘affiliate_area_creatives’, allows active affiliates to access their dashboard. It generates a unique section on the affiliate dashboard, specifically the ‘creatives’ tab, displaying promotional materials for affiliates. The shortcode ensures the user is an active affiliate before rendering the content.
Shortcode: [affiliate_area_creatives]
Examples and Usage
Basic example – An affiliate can use this shortcode to display their unique creatives dashboard on any page of the website.
[affiliate_area_creatives]
PHP Function Code
In case you have difficulties debugging what causing issues with [affiliate_area_creatives]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'affiliate_area_creatives', array( $this, 'affiliate_area_creatives' ) );
Shortcode PHP function:
function affiliate_area_creatives( $atts, $content = null ) {
if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) {
return;
}
ob_start();
echo '<div id="affwp-affiliate-dashboard">';
affiliate_wp()->templates->get_template_part( 'dashboard-tab', 'creatives' );
echo '</div>';
$content = ob_get_clean();
return do_shortcode( $content );
}
Code file location:
affiliatewp-affiliate-area-shortcodes/affiliatewp-affiliate-area-shortcodes/includes/class-shortcodes.php
Affiliatewp Affiliate Area [affiliate_area_referrals] Shortcode
The AffiliateWP-Affiliate-Area-Shortcodes plugin shortcode, ‘affiliate_area_referrals’, displays the referral tab in the affiliate dashboard. This shortcode checks if the user is an active affiliate before displaying the ‘referrals’ tab. It uses the ‘dashboard-tab’ template part for ‘referrals’ within a div with the ID ‘affwp-affiliate-dashboard’.
Shortcode: [affiliate_area_referrals]
Examples and Usage
Basic example – The shortcode ‘affiliate_area_referrals’ is used to display the affiliate dashboard with the ‘referrals’ tab. It is important to note that this shortcode only works if the user is an active affiliate.
[affiliate_area_referrals /]
PHP Function Code
In case you have difficulties debugging what causing issues with [affiliate_area_referrals]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'affiliate_area_referrals', array( $this, 'affiliate_area_referrals' ) );
Shortcode PHP function:
function affiliate_area_referrals( $atts, $content = null ) {
if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) {
return;
}
ob_start();
echo '<div id="affwp-affiliate-dashboard">';
affiliate_wp()->templates->get_template_part( 'dashboard-tab', 'referrals' );
echo '</div>';
$content = ob_get_clean();
return do_shortcode( $content );
}
Code file location:
affiliatewp-affiliate-area-shortcodes/affiliatewp-affiliate-area-shortcodes/includes/class-shortcodes.php
Affiliatewp Affiliate Area [affiliate_area_stats] Shortcode
The AffiliateWP Affiliate Area Shortcodes plugin’s ‘affiliate_area_stats’ shortcode is designed to display affiliate statistics. This shortcode checks if the user is an active affiliate. If so, it opens a buffer, creates a div with the id “affwp-affiliate-dashboard”, and fetches the ‘stats’ part of the affiliate dashboard. The content is then processed through any additional shortcodes before being returned.
Shortcode: [affiliate_area_stats]
Examples and Usage
Basic example – The shortcode [affiliate_area_stats] can be used to display the affiliate area statistics on your WordPress page. This shortcode doesn’t take any parameters.
[affiliate_area_stats /]
Advanced examples
Although the given shortcode does not accept parameters directly, we can use WordPress do_shortcode function with parameters to modify the output. However, this requires changes to the function code itself and is recommended for advanced users only.
echo do_shortcode('[affiliate_area_stats id="123" color="red"]');
In the above example, the shortcode is being run within a PHP echo statement. The ‘id’ and ‘color’ parameters are being passed to the shortcode, but they won’t have any effect unless the function ‘affiliate_area_stats’ is modified to accept and use these parameters.
PHP Function Code
In case you have difficulties debugging what causing issues with [affiliate_area_stats]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'affiliate_area_stats', array( $this, 'affiliate_area_stats' ) );
Shortcode PHP function:
function affiliate_area_stats( $atts, $content = null ) {
if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) {
return;
}
ob_start();
echo '<div id="affwp-affiliate-dashboard">';
affiliate_wp()->templates->get_template_part( 'dashboard-tab', 'stats' );
echo '</div>';
$content = ob_get_clean();
return do_shortcode( $content );
}
Code file location:
affiliatewp-affiliate-area-shortcodes/affiliatewp-affiliate-area-shortcodes/includes/class-shortcodes.php
Affiliatewp Affiliate Area [affiliate_area_urls] Shortcode
The AffiliateWP-Affiliate-Area-Shortcodes plugin’s shortcode, ‘affiliate_area_urls’, is designed to display the affiliate URLs dashboard tab. This shortcode checks if the user is an active affiliate. If true, it outputs the affiliate’s dashboard with their unique URLs. It’s a useful tool for affiliates to track their referrals.
Shortcode: [affiliate_area_urls]
Examples and Usage
Basic example – The following example demonstrates the basic usage of the ‘affiliate_area_urls’ shortcode. This shortcode does not require any parameters, and it’s used to display the affiliate URLs dashboard for active affiliates.
[affiliate_area_urls /]
PHP Function Code
In case you have difficulties debugging what causing issues with [affiliate_area_urls]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'affiliate_area_urls', array( $this, 'affiliate_area_urls' ) );
Shortcode PHP function:
function affiliate_area_urls( $atts, $content = null ) {
if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) {
return;
}
ob_start();
echo '<div id="affwp-affiliate-dashboard">';
affiliate_wp()->templates->get_template_part( 'dashboard-tab', 'urls' );
echo '</div>';
$content = ob_get_clean();
return do_shortcode( $content );
}
Code file location:
affiliatewp-affiliate-area-shortcodes/affiliatewp-affiliate-area-shortcodes/includes/class-shortcodes.php
Affiliatewp Affiliate Area [affiliate_area_payouts] Shortcode
The AffiliateWP-affiliate-area-shortcodes plugin shortcode, ‘affiliate_area_payouts’, is designed to display the affiliate’s payout information. This shortcode only works if the user is an active affiliate. It initiates by checking the user’s affiliate status. If the user is not an active affiliate, the function ends. If they are, it begins output buffering and creates a div with the ID ‘affwp-affiliate-dashboard’. Next, it calls a template part for the dashboard tab labeled ‘payouts’. After this, it cleans the output buffer and returns the buffered content. This allows for the display of the affiliate’s payout information in a clean, organized manner.
Shortcode: [affiliate_area_payouts]
Examples and Usage
Basic example – The shortcode ‘affiliate_area_payouts’ displays the affiliate payouts in the affiliate dashboard area. It does not require any parameters or attributes to function.
[affiliate_area_payouts /]
Advanced examples
The ‘affiliate_area_payouts’ shortcode does not have any built-in parameters or attributes. However, if you want to extend its functionality, you can add custom parameters via the ‘add_shortcode’ function in your theme’s functions.php file or in a custom plugin. Please note that this requires advanced knowledge of PHP and WordPress development.
For example, you might want to add a ‘status’ attribute to the shortcode, allowing you to display payouts with a specific status. Here’s how you might do that:
function affiliate_area_payouts( $atts, $content = null ) {
// Extract the attributes
$atts = shortcode_atts( array(
'status' => 'unpaid', // Default status
), $atts, 'affiliate_area_payouts' );
if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) {
return;
}
ob_start();
echo '';
// Get payouts with the specified status
$payouts = affwp_get_affiliate_payouts( get_current_user_id(), $atts['status'] );
foreach ( $payouts as $payout ) {
// Display the payout details here
}
echo '';
$content = ob_get_clean();
return do_shortcode( $content );
}
add_shortcode( 'affiliate_area_payouts', 'affiliate_area_payouts' );
This modified shortcode can be used like this:
[affiliate_area_payouts status="paid" /]
This will display all the affiliate payouts with the status ‘paid’.
PHP Function Code
In case you have difficulties debugging what causing issues with [affiliate_area_payouts]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'affiliate_area_payouts', array( $this, 'affiliate_area_payouts' ) );
Shortcode PHP function:
function affiliate_area_payouts( $atts, $content = null ) {
if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) {
return;
}
ob_start();
echo '<div id="affwp-affiliate-dashboard">';
affiliate_wp()->templates->get_template_part( 'dashboard-tab', 'payouts' );
echo '</div>';
$content = ob_get_clean();
return do_shortcode( $content );
}
Code file location:
affiliatewp-affiliate-area-shortcodes/affiliatewp-affiliate-area-shortcodes/includes/class-shortcodes.php
Affiliatewp Affiliate Area [affiliate_area_visits] Shortcode
The ‘affiliate_area_visits’ shortcode from AffiliateWP-Affiliate-Area-Shortcodes plugin displays an affiliate’s visit data on their dashboard. This shortcode checks if the user is an active affiliate. If true, it starts output buffering, creates a div with the id ‘affwp-affiliate-dashboard’, and fetches the ‘visits’ dashboard tab template. The output is then returned.
Shortcode: [affiliate_area_visits]
Examples and Usage
Basic example – The shortcode ‘affiliate_area_visits’ is used to display the affiliate area visits dashboard. This is useful for affiliates who want to track their visits and performance.
[affiliate_area_visits /]
Advanced examples
While the ‘affiliate_area_visits’ shortcode does not accept parameters directly, you can manipulate the content displayed using additional shortcodes within the ‘affiliate_area_visits’ shortcode. Here’s an example of using the ‘affiliate_area_visits’ shortcode along with the ‘affwp_affiliate_dashboard_tabs’ shortcode to customize the dashboard tabs for the affiliate.
[affiliate_area_visits]
[affwp_affiliate_dashboard_tabs]
[/affiliate_area_visits]
Note: The ‘affwp_affiliate_dashboard_tabs’ shortcode is used to display the dashboard tabs for the affiliate. You can customize the tabs by adding or removing shortcodes within the ‘affwp_affiliate_dashboard_tabs’ shortcode.
Also, please remember that these shortcodes will only work if the user is an active affiliate. If not, these shortcodes will return nothing.
PHP Function Code
In case you have difficulties debugging what causing issues with [affiliate_area_visits]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'affiliate_area_visits', array( $this, 'affiliate_area_visits' ) );
Shortcode PHP function:
function affiliate_area_visits( $atts, $content = null ) {
if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) {
return;
}
ob_start();
echo '<div id="affwp-affiliate-dashboard">';
affiliate_wp()->templates->get_template_part( 'dashboard-tab', 'visits' );
echo '</div>';
$content = ob_get_clean();
return do_shortcode( $content );
}
Code file location:
affiliatewp-affiliate-area-shortcodes/affiliatewp-affiliate-area-shortcodes/includes/class-shortcodes.php
Affiliatewp Affiliate Area [affiliate_referrals] Shortcode
The ‘affiliate_referrals’ shortcode from the AffiliateWP plugin, allows affiliates to view their referral count. Based on the status attribute, it displays either ‘paid’ or ‘unpaid’ referrals. If no status is specified, it returns null. This shortcode can only be used by active affiliates.
Shortcode: [affiliate_referrals]
Parameters
Here is a list of all possible affiliate_referrals shortcode parameters and attributes:
status
– Determines the type of referrals to display, “paid” or “unpaid”.
Examples and Usage
Basic Example – Show the total number of affiliate referrals
[affiliate_referrals /]
PHP Function Code
In case you have difficulties debugging what causing issues with [affiliate_referrals]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'affiliate_referrals', array( $this, 'affiliate_referrals' ) );
Shortcode PHP function:
function affiliate_referrals( $atts, $content = null ) {
if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) {
return;
}
$atts = shortcode_atts( array(
'status' => ''
), $atts, 'affiliate_referrals' );
switch ( $atts['status'] ) {
case 'paid':
$content = affwp_count_referrals( affwp_get_affiliate_id(), 'paid' );
break;
case 'unpaid':
$content = affwp_count_referrals( affwp_get_affiliate_id(), 'unpaid' );
break;
}
return do_shortcode( $content );
}
Code file location:
affiliatewp-affiliate-area-shortcodes/affiliatewp-affiliate-area-shortcodes/includes/class-shortcodes.php
Affiliatewp Affiliate Area [affiliate_earnings] Shortcode
The AffiliateWP-Affiliate-Area-Shortcodes plugin shortcode, ‘affiliate_earnings’, displays the earnings of an active affiliate. It checks if the user is an active affiliate. If true, it returns their earnings based on the specified status – ‘paid’ or ‘unpaid’.
Shortcode: [affiliate_earnings]
Parameters
Here is a list of all possible affiliate_earnings shortcode parameters and attributes:
status
– defines the type of affiliate earnings to display
Possible values for the ‘status’ parameter are:
paid
– shows the affiliate’s earnings that have been paidunpaid
– displays the affiliate’s earnings that are yet to be paid
Examples and Usage
Basic example – Display the total earnings of an active affiliate
[affiliate_earnings /]
In this basic usage, the shortcode ‘affiliate_earnings’ will display the total earnings of an active affiliate. This is useful for affiliates who want to keep track of their total earnings. No additional parameters or attributes are necessary for this basic usage.
Advanced examples
Display the total paid earnings of an active affiliate
[affiliate_earnings status="paid" /]
In this advanced usage, the shortcode ‘affiliate_earnings’ with the ‘status’ attribute set to ‘paid’ will display the total paid earnings of an active affiliate. This is useful for affiliates who want to keep track of their paid earnings.
Display the total unpaid earnings of an active affiliate
[affiliate_earnings status="unpaid" /]
In this advanced usage, the shortcode ‘affiliate_earnings’ with the ‘status’ attribute set to ‘unpaid’ will display the total unpaid earnings of an active affiliate. This is useful for affiliates who want to keep track of their unpaid earnings.
PHP Function Code
In case you have difficulties debugging what causing issues with [affiliate_earnings]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'affiliate_earnings', array( $this, 'affiliate_earnings' ) );
Shortcode PHP function:
function affiliate_earnings( $atts, $content = null ) {
if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) {
return;
}
$atts = shortcode_atts( array(
'status' => ''
), $atts, 'affiliate_earnings' );
switch ( $atts['status'] ) {
case 'paid':
$content = affwp_get_affiliate_earnings( affwp_get_affiliate_id(), true );
break;
case 'unpaid':
$content = affwp_get_affiliate_unpaid_earnings( affwp_get_affiliate_id(), true );
break;
}
return do_shortcode( $content );
}
Code file location:
affiliatewp-affiliate-area-shortcodes/affiliatewp-affiliate-area-shortcodes/includes/class-shortcodes.php
Affiliatewp Affiliate Area [affiliate_visits] Shortcode
The AffiliateWP Affiliate Area Shortcodes plugin shortcode ‘affiliate_visits’ tracks and counts the visits made by an active affiliate. This shortcode returns the total count of visits made by an affiliate. It checks if the user is an active affiliate before returning the visit count.
Shortcode: [affiliate_visits]
Examples and Usage
Basic Example – The following shortcode displays the total number of visits made by an affiliate. The affiliate must be active for this shortcode to function.
[affiliate_visits /]
Advanced Examples
In the context of the ‘affiliate_visits’ shortcode, there are no additional attributes available. However, you can use it within other shortcodes or functions to display or manipulate the data further. Below is an example of how you might use this shortcode within a conditional statement in another shortcode or function.
add_shortcode( 'custom_affiliate_data', 'custom_affiliate_data' );
function custom_affiliate_data( $atts, $content = null ) {
if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) {
return;
}
$visits = do_shortcode( '[affiliate_visits]' );
if ( $visits > 100 ) {
$content = "Congratulations! You have made over 100 visits!";
} else {
$content = "Keep going! You have made " . $visits . " visits so far.";
}
return $content;
}
In this example, the ‘custom_affiliate_data’ shortcode uses the ‘affiliate_visits’ shortcode to get the number of visits made by an affiliate. It then checks if the number of visits is more than 100. If it is, a congratulatory message is displayed. If not, a motivational message is displayed along with the number of visits made so far.
PHP Function Code
In case you have difficulties debugging what causing issues with [affiliate_visits]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'affiliate_visits', array( $this, 'affiliate_visits' ) );
Shortcode PHP function:
function affiliate_visits( $atts, $content = null ) {
if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) {
return;
}
$content = affwp_count_visits( affwp_get_affiliate_id() );
return do_shortcode( $content );
}
Code file location:
affiliatewp-affiliate-area-shortcodes/affiliatewp-affiliate-area-shortcodes/includes/class-shortcodes.php
Affiliatewp Affiliate Area [affiliate_conversion_rate] Shortcode
The AffiliateWP-affiliate-area-shortcodes plugin shortcode ‘affiliate_conversion_rate’ calculates the conversion rate for an active affiliate. It checks if the user is an active affiliate and fetches their conversion rate.
Shortcode: [affiliate_conversion_rate]
Examples and Usage
Basic example – The shortcode ‘affiliate_conversion_rate’ is used to display the conversion rate of the affiliate. It does not require any parameters or attributes.
[affiliate_conversion_rate /]
Advanced examples
In the advanced usage of the ‘affiliate_conversion_rate’ shortcode, we can add custom attributes or parameters. However, based on the provided PHP function, this shortcode does not accept any parameters. The function checks if the user is an affiliate and if the affiliate is active. If both conditions are met, it retrieves and displays the affiliate’s conversion rate.
Although the ‘affiliate_conversion_rate’ shortcode does not accept parameters, other shortcodes within the AffiliateWP plugin do. For instance, you can use the ‘affiliate_area’ shortcode to display the affiliate area, and you can customize its output using parameters like ‘tabs’ or ‘redirect’.
Here is an example:
[affiliate_area tabs="no" redirect="yes" /]
In this example, the ‘tabs’ parameter is set to ‘no’, which means the affiliate area will not display tabs. The ‘redirect’ parameter is set to ‘yes’, which means users will be redirected to a specific page if they are not affiliates.
PHP Function Code
In case you have difficulties debugging what causing issues with [affiliate_conversion_rate]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'affiliate_conversion_rate', array( $this, 'affiliate_conversion_rate' ) );
Shortcode PHP function:
function affiliate_conversion_rate( $atts, $content = null ) {
if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) {
return;
}
$content = affwp_get_affiliate_conversion_rate( affwp_get_affiliate_id() );
return do_shortcode( $content );
}
Code file location:
affiliatewp-affiliate-area-shortcodes/affiliatewp-affiliate-area-shortcodes/includes/class-shortcodes.php
Affiliatewp Affiliate Area [affiliate_commission_rate] Shortcode
The AffiliateWP Affiliate Area Shortcodes plugin’s shortcode, ‘affiliate_commission_rate’, is designed to display the commission rate of an active affiliate. This shortcode checks if the user is an active affiliate and then retrieves their commission rate. It’s a useful tool for affiliates to monitor their earnings rate.
Shortcode: [affiliate_commission_rate]
Examples and Usage
Basic example – A simple usage of the ‘affiliate_commission_rate’ shortcode without any additional attributes.
[affiliate_commission_rate /]
Advanced examples
While the ‘affiliate_commission_rate’ shortcode doesn’t accept any additional attributes by default, you can modify the function to accept parameters. Here’s an example where we’ve modified the function to accept a ‘format’ attribute, which determines whether the commission rate is returned as a decimal or a percentage.
function affiliate_commission_rate( $atts, $content = null ) {
if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) {
return;
}
$atts = shortcode_atts( array(
'format' => 'decimal'
), $atts, 'affiliate_commission_rate' );
$content = affwp_get_affiliate_rate( affwp_get_affiliate_id(), $atts['format'] === 'percentage' );
return do_shortcode( $content );
}
With this modification, you can now use the ‘format’ attribute in your shortcode like this:
[affiliate_commission_rate format="percentage" /]
This will display the affiliate’s commission rate as a percentage rather than a decimal.
PHP Function Code
In case you have difficulties debugging what causing issues with [affiliate_commission_rate]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'affiliate_commission_rate', array( $this, 'affiliate_commission_rate' ) );
Shortcode PHP function:
function affiliate_commission_rate( $atts, $content = null ) {
if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) {
return;
}
$content = affwp_get_affiliate_rate( affwp_get_affiliate_id(), true );
return do_shortcode( $content );
}
Code file location:
affiliatewp-affiliate-area-shortcodes/affiliatewp-affiliate-area-shortcodes/includes/class-shortcodes.php
Affiliatewp Affiliate Area [affiliate_campaign_stats] Shortcode
The AffiliateWP Affiliate Area Shortcodes plugin’s shortcode, ‘affiliate_campaign_stats’, enables affiliates to view their campaign statistics. This shortcode displays a table in the affiliate dashboard, presenting data on campaign visits, unique links, conversions, and conversion rates. If no campaigns exist, a message is displayed.
Shortcode: [affiliate_campaign_stats]
Examples and Usage
Basic example – A simple usage of the ‘affiliate_campaign_stats’ shortcode without any additional attributes.
[affiliate_campaign_stats /]
PHP Function Code
In case you have difficulties debugging what causing issues with [affiliate_campaign_stats]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'affiliate_campaign_stats', array( $this, 'affiliate_campaign_stats' ) );
Shortcode PHP function:
function affiliate_campaign_stats( $atts, $content = null ) {
if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) {
return;
}
ob_start();
?>
<div id="affwp-affiliate-dashboard-campaign-stats" class="affwp-tab-content">
<table class="affwp-table">
<thead>
<tr>
<th><?php _e( 'Campaign', 'affiliatewp-affiliate-area-shortcodes' ); ?></th>
<th><?php _e( 'Visits', 'affiliatewp-affiliate-area-shortcodes' ); ?></th>
<th><?php _e( 'Unique Links', 'affiliatewp-affiliate-area-shortcodes' ); ?></th>
<th><?php _e( 'Converted', 'affiliatewp-affiliate-area-shortcodes' ); ?></th>
<th><?php _e( 'Conversion Rate', 'affiliatewp-affiliate-area-shortcodes' ); ?></th>
</tr>
</thead>
<tbody>
<?php if( $campaigns = affwp_get_affiliate_campaigns( affwp_get_affiliate_id() ) ) : ?>
<?php foreach( $campaigns as $campaign ) : ?>
<tr>
<td><?php echo ! empty( $campaign->campaign ) ? esc_html( $campaign->campaign ) : __( 'None set', 'affiliatewp-affiliate-area-shortcodes' ); ?></td>
<td><?php echo esc_html( $campaign->visits ); ?></td>
<td><?php echo esc_html( $campaign->unique_visits ); ?></td>
<td><?php echo esc_html( $campaign->referrals ); ?></td>
<td><?php echo esc_html( affwp_format_amount( $campaign->conversion_rate ) ); ?>%</td>
</tr>
<?php endforeach; ?>
<?php else : ?>
<tr>
<td colspan="5"><?php _e( 'You have no referrals or visits that included a campaign name.', 'affiliatewp-affiliate-area-shortcodes' ); ?></td>
</tr>
<?php endif; ?>
</tbody>
</table>
<?php do_action( 'affwp_affiliate_dashboard_after_campaign_stats', affwp_get_affiliate_id() ); ?>
</div>
<?php
$content = ob_get_clean();
return do_shortcode( $content );
}
Code file location:
affiliatewp-affiliate-area-shortcodes/affiliatewp-affiliate-area-shortcodes/includes/class-shortcodes.php
Affiliatewp Affiliate Area [affiliate_id] Shortcode
The AffiliateWP Affiliate Area Shortcodes plugin’s shortcode, ‘affiliate_id’, is designed to retrieve and display the active affiliate’s ID. Once inserted, this shortcode checks if the user is an active affiliate. If true, it fetches and returns the affiliate’s ID. If not, it returns nothing. This shortcode is useful for personalizing affiliate pages.
Shortcode: [affiliate_id]
Examples and Usage
Basic example – Display the affiliate ID for the currently logged in affiliate.
[affiliate_id /]
PHP Function Code
In case you have difficulties debugging what causing issues with [affiliate_id]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'affiliate_id', array( $this, 'affiliate_id' ) );
Shortcode PHP function:
function affiliate_id( $atts, $content = null ) {
if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) {
return;
}
$content = affwp_get_affiliate_id();
return do_shortcode( $content );
}
Code file location:
affiliatewp-affiliate-area-shortcodes/affiliatewp-affiliate-area-shortcodes/includes/class-shortcodes.php
Affiliatewp Affiliate Area [affiliate_username] Shortcode
The AffiliateWP Affiliate Area Shortcodes plugin provides the ‘[affiliate_username]’ shortcode. This shortcode displays the username of an active affiliate when placed on a page. It verifies if the user is an active affiliate before rendering the username.
Shortcode: [affiliate_username]
Examples and Usage
Basic example – This shortcode will display the username of the affiliate, but only if the user is an active affiliate. If the user is not an active affiliate, the shortcode will not display anything.
[affiliate_username /]
PHP Function Code
In case you have difficulties debugging what causing issues with [affiliate_username]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'affiliate_username', array( $this, 'affiliate_username' ) );
Shortcode PHP function:
function affiliate_username( $atts, $content = null ) {
if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) {
return;
}
$content = affwp_get_affiliate_username();
return do_shortcode( $content );
}
Code file location:
affiliatewp-affiliate-area-shortcodes/affiliatewp-affiliate-area-shortcodes/includes/class-shortcodes.php
Affiliatewp Affiliate Area [affiliate_name] Shortcode
The AffiliateWP Affiliate Area Shortcodes plugin shortcode ‘affiliate_name’ displays the affiliate’s name. It checks if the user is an active affiliate before rendering the name. The ‘first_name_only’ attribute allows you to display only the affiliate’s first name. If set to ‘yes’, it will fetch the current user’s first name. Otherwise, it obtains the full affiliate name.
Shortcode: [affiliate_name]
Parameters
Here is a list of all possible affiliate_name shortcode parameters and attributes:
first_name_only
– Display only the first name of the affiliate when set to ‘yes’
Examples and Usage
Basic example – Show the full name of the active affiliate
[affiliate_name /]
Advanced examples
Display only the first name of the active affiliate by setting the ‘first_name_only’ attribute to ‘yes’. This shortcode will check if the user is an active affiliate and if so, it will return the first name of the user.
[affiliate_name first_name_only=yes /]
Another example is to use this shortcode inside another shortcode. This nested shortcode will first execute the ‘affiliate_name’ shortcode and then the output will be used as the content for the outer shortcode.
[outer_shortcode][affiliate_name /][/outer_shortcode]
Please note that in all these examples, the shortcode will return nothing if the user is not an active affiliate. This is a safety measure to ensure that only valid affiliates can use this shortcode.
PHP Function Code
In case you have difficulties debugging what causing issues with [affiliate_name]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'affiliate_name', array( $this, 'affiliate_name' ) );
Shortcode PHP function:
function affiliate_name( $atts, $content = null ) {
if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) {
return;
}
$atts = shortcode_atts( array(
'first_name_only' => ''
), $atts, 'affiliate_name' );
if ( isset( $atts['first_name_only'] ) && 'yes' === $atts['first_name_only'] ) {
$current_user = wp_get_current_user();
$content = $current_user->user_firstname;
} else {
$content = affiliate_wp()->affiliates->get_affiliate_name( affwp_get_affiliate_id() );
}
return do_shortcode( $content );
}
Code file location:
affiliatewp-affiliate-area-shortcodes/affiliatewp-affiliate-area-shortcodes/includes/class-shortcodes.php
Affiliatewp Affiliate Area [affiliate_website] Shortcode
The AffiliateWP-affiliate-area-shortcodes plugin shortcode ‘affiliate_website’ is designed to retrieve and display the website URL of a currently active affiliate user. This shortcode checks if the logged-in user is an active affiliate. If true, it fetches the user’s website URL from their profile and displays it on the page.
Shortcode: [affiliate_website]
Examples and Usage
Basic example – The affiliate’s website URL is displayed using the ‘affiliate_website’ shortcode without any parameters.
[affiliate_website /]
Advanced examples
Unfortunately, the ‘affiliate_website’ shortcode does not accept any parameters, so there are no advanced examples to provide. This shortcode simply returns the URL of the website associated with the current user, if the user is an active affiliate. If the user is not an active affiliate, the shortcode returns nothing.
However, you can use this shortcode in conjunction with other shortcodes or within a text block to display the affiliate’s website URL in a specific context or format. Here is an example of how you might use the ‘affiliate_website’ shortcode within a paragraph of text:
<p>Check out my affiliate website: [affiliate_website /]</p>
PHP Function Code
In case you have difficulties debugging what causing issues with [affiliate_website]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'affiliate_website', array( $this, 'affiliate_website' ) );
Shortcode PHP function:
function affiliate_website( $atts, $content = null ) {
if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) {
return;
}
$current_user = wp_get_current_user();
$content = $current_user->user_url;
return do_shortcode( $content );
}
Code file location:
affiliatewp-affiliate-area-shortcodes/affiliatewp-affiliate-area-shortcodes/includes/class-shortcodes.php
Affiliatewp Affiliate Area [affiliate_area_notices] Shortcode
The AffiliateWP-Affiliate-Area-Shortcodes plugin shortcode, ‘affiliate_area_notices’, is designed to display various status messages for affiliates. The shortcode checks if the user is logged in and an affiliate. If they are, it generates a status message based on their affiliate account status. This could be ‘pending’, ‘inactive’, ‘rejected’, or ‘profile updated’. The message is then displayed within a paragraph element on the affiliate’s page.
Shortcode: [affiliate_area_notices]
Parameters
Here is a list of all possible affiliate_area_notices shortcode parameters and attributes:
pending
– message for an affiliate account awaiting approvalinactive
– message for an inactive affiliate accountrejected
– message for a rejected affiliate account requestprofile_updated
– message for a successfully updated affiliate profile
Examples and Usage
Basic example – A simple usage of the ‘affiliate_area_notices’ shortcode without any additional parameters. This will display the default notices based on the affiliate’s status.
[affiliate_area_notices /]
Advanced examples
Customizing the ‘affiliate_area_notices’ shortcode by specifying the ‘pending’, ‘inactive’, and ‘rejected’ parameters. This allows you to customize the messages displayed to affiliates based on their status.
[affiliate_area_notices pending="Your account is pending approval." inactive="Your account is not currently active." rejected="Your affiliate request has been denied." /]
Further customization of the ‘affiliate_area_notices’ shortcode by specifying all four parameters: ‘pending’, ‘inactive’, ‘rejected’, and ‘profile_updated’. This gives you full control over the messages displayed to affiliates based on their status and actions.
[affiliate_area_notices pending="Your account is pending approval." inactive="Your account is not currently active." rejected="Your affiliate request has been denied." profile_updated="Your profile has been successfully updated." /]
PHP Function Code
In case you have difficulties debugging what causing issues with [affiliate_area_notices]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'affiliate_area_notices', array( $this, 'affiliate_area_notices' ) );
Shortcode PHP function:
function affiliate_area_notices( $atts, $content = null ) {
if ( ! ( is_user_logged_in() && affwp_is_affiliate() ) ) {
return;
}
$atts = shortcode_atts( array(
'pending' => __( 'Your affiliate account is pending approval', 'affiliatewp-affiliate-area-shortcodes' ),
'inactive' => __( 'Your affiliate account is not active', 'affiliatewp-affiliate-area-shortcodes' ),
'rejected' => __( 'Your affiliate account request has been rejected', 'affiliatewp-affiliate-area-shortcodes' ),
'profile_updated' => __( 'Your affiliate profile has been updated', 'affiliatewp-affiliate-area-shortcodes' )
), $atts, 'affiliate_area_notices' );
if ( ! empty( $_GET['affwp_notice'] ) && 'profile-updated' == $_GET['affwp_notice'] ) {
$notice = $atts['profile_updated'];
}
if ( 'pending' == affwp_get_affiliate_status( affwp_get_affiliate_id() ) ) {
$notice = $atts['pending'];
} elseif ( 'inactive' == affwp_get_affiliate_status( affwp_get_affiliate_id() ) ) {
$notice = $atts['inactive'];
} elseif ( 'rejected' == affwp_get_affiliate_status( affwp_get_affiliate_id() ) ) {
$notice = $atts['rejected'];
} else {
$notice = '';
}
ob_start();
if ( $notice ): ?>
<p class="affwp-notice"><?php echo $notice; ?></p>
<?php endif;
$content = ob_get_clean();
return do_shortcode( $content );
}
Code file location:
affiliatewp-affiliate-area-shortcodes/affiliatewp-affiliate-area-shortcodes/includes/class-shortcodes.php
Affiliatewp Affiliate Area [affiliate_logout] Shortcode
The AffiliateWP-Affiliate-Area-Shortcodes plugin shortcode ‘affiliate_logout’ allows active affiliates to log out from their account. This shortcode first checks if the user is an active affiliate. If they are, it generates a logout URL. The logout URL either redirects to the affiliate login page or the home page, depending on the settings. The shortcode then creates a ‘Log out’ link for the affiliate.
Shortcode: [affiliate_logout]
Examples and Usage
Basic example – The shortcode for affiliate logout without any additional attributes. It will log out the affiliate and redirect them to the default login page or home page.
[affiliate_logout /]
Advanced examples
Using the shortcode with a custom redirect URL. In this example, the affiliate will be logged out and redirected to the ‘affiliates’ page. The ‘affwp_aas_logout_redirect’ filter is used for this purpose.
add_filter( 'affwp_aas_logout_redirect', function() {
return get_permalink( get_page_by_path( 'affiliates' ) );
} );
[affiliate_logout /]
Using the shortcode with a custom logout link. The ‘affwp_aas_logout_link’ filter is used to modify the logout link. In this example, the logout link text is changed to ‘Sign out’.
add_filter( 'affwp_aas_logout_link', function( $link ) {
return str_replace( 'Log out', 'Sign out', $link );
} );
[affiliate_logout /]
PHP Function Code
In case you have difficulties debugging what causing issues with [affiliate_logout]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'affiliate_logout', array( $this, 'affiliate_logout' ) );
Shortcode PHP function:
function affiliate_logout( $atts, $content = null ) {
if ( ! ( affwp_is_affiliate() && affwp_is_active_affiliate() ) ) {
return;
}
$redirect = function_exists( 'affiliate_wp' ) && affiliate_wp()->settings->get( 'affiliates_page' ) ? affiliate_wp()->login->get_login_url() : home_url();
$redirect = apply_filters( 'affwp_aas_logout_redirect', $redirect );
$content = apply_filters( 'affwp_aas_logout_link', '<a href=" ' . wp_logout_url( $redirect ) . '">' . __( 'Log out', 'affiliatewp-affiliate-area-shortcodes' ) . '</a>', $redirect );
return do_shortcode( $content );
}
Code file location:
affiliatewp-affiliate-area-shortcodes/affiliatewp-affiliate-area-shortcodes/includes/class-shortcodes.php
Conclusion
Now that you’ve learned how to embed the AffiliateWP Affiliate Area Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply