Posted on Leave a comment

affiliates_is_affiliate_by_id

If you are using Affiliates by itthinx, and you need to display different content per affiliates, then you are in correct place 😉
This shortcode can help you:
add_shortcode ( 'affiliates_is_affiliate_by_id', 'affiliates_is_affiliate_by_id' );
function affiliates_is_affiliate_by_id($atts, $content = null) {
extract ( shortcode_atts ( array (
'id' => '0'
), $atts ) );
remove_shortcode ( 'affiliates_is_affiliate_by_id' );
$content = do_shortcode ( $content );
add_shortcode ( 'affiliates_is_affiliate_by_id', 'affiliates_is_affiliate_by_id' );
$output = "";
if (affiliates_user_is_affiliate ( get_current_user_id () )) {
if (affiliates_get_user_affiliate ( get_current_user_id () )[0] == $id) {
$output .= $content;
}
}
return $output;
}

Add this code in your functions.php theme file.
Example of use:
[affiliates_is_affiliate_by_id id="42"]
Only affiliate with id 42 can see this text.
[/affiliates_is_affiliate_by_id]
[affiliates_is_affiliate_by_id id="47"]
Only affiliate with id 47 can see this text.
[/affiliates_is_affiliate_by_id]

Leave a Reply

Your email address will not be published. Required fields are marked *