Your cart is currently empty!
if Affiliate Partner is logged in
—
by
Hey!
I want to show an affilitate link in sidebar if affiliate partner is logged in.
This is my code:
if( is_user_logged_in() && (current_user_can('customer')){
echo do_shortcode( '[affiliates_affiliate_link /]' );
}
I can’t find in the documentation if the affiliate has a userrole or how to check if an affiliate partner ist logged in.
Has anybody a tip for me?
Greetings
Matthias
Posted in Affiliates Pro
Comments
3 responses to “if Affiliate Partner is logged in”
Hi Lars,
You can use the [affiliates_is_affiliates /] shortcode, or using the API, you have available the affiliates_user_is_affiliate function.
Kind Regards,
Antonio B.
Hey Antonio,
Thx! This is my Solution in the sidebar for product-pages:
$current_user = wp_get_current_user();
$currentuserid = $current_user->ID;
$posturl = get_permalink( $post->ID );
$posttitle = get_the_title();
if ( $currentuserid > 0 ) {
if ( affiliates_user_is_affiliate( $currentuserid ) ) {
echo 'Ihr Affiliate-Link zum kopieren:';
echo do_shortcode('[affiliates_affiliate_link url="' . $posturl . '" content="' . $posttitle . '" render="code" /]');
}
}
Perfect, thanks for sharing !!!
Cheers