Your cart is currently empty!
Get Affiliate ID of viewed user
—
by
Hi there,
How can I retrieve the affiliate ID of the user currently being viewed?
Posted in Affiliates Pro
—
by
Hi there,
How can I retrieve the affiliate ID of the user currently being viewed?
Comments
7 responses to “Get Affiliate ID of viewed user”
Thanks so much, that works a treat! 😀
Much appreciated!!
Perfect 🙂
Hi Antonio,
Thanks for your help so far. I have a page which lists all the users on the site. Using the shortcode, it echos “2” as Afilliate ID for every user, which is the affiliate ID of my admin account (thus the logged in user ID).
Hi Rudi,
Ok, you can use the Affiliates API to create your how solution.
I have created this shortcode. If you add this code in your functions.php theme file, it should work:
add_shortcode( 'affiliates_affiliate_id_by_user', 'my_affiliates_affiliate_id_by_user' );
function my_affiliates_affiliate_id_by_user ($atts, $content = null ) {
$output = "";
$options = shortcode_atts(
array(
'id' => null
),
$atts
);
extract( $options );
if ( $id !== null ) {
if ( affiliates_user_is_affiliate( $id ) ) {
$affiliate_ids = affiliates_get_user_affiliate( $id );
if ( ( $affiliate_ids ) && ( sizeof( $affiliate_ids ) > 0 ) ) {
$output .= $affiliate_ids[0];
}
}
}
return $output;
}
If the user id is 25, the use is:
[affiliates_affiliate_id_by_user id="25" /]
Kind Regards,
Antonio B.
Hi there Antonio.
That returns the ID of the logged in user. I need to retrieve the ID of the user being viewed (ie, to generate a custom table which includes the unique referral codes of each user).
Kind regards,
Rudi
Hi Rudi,
The [affiliates_id] shortcode display the current affiliate’s ID, not the ID of the logged in user.
Really I don’t know exactly what do you want to do. Please give us more information. Remember that from Affiliates->Manager Affiliates you can see the affiliate IDs and their urls.
Kind Regards,
Antonio B.
Hi Rudi,
you can use the [affiliates_id] shortcode.
Kind Regards,
Antonio B.