if Affiliate Partner is logged in

Posted in

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

3 Responses to if Affiliate Partner is logged in

  1. antonio April 7, 2017 at 6:16 am #

    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.

    • Lars April 7, 2017 at 10:02 am #

      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" /]');
      }
      }

      • antonio April 10, 2017 at 6:20 am #

        Perfect, thanks for sharing !!!
        Cheers

We use cookies to optimize your experience on our site and assume you're OK with that if you stay.
OK, hide this message.

Affiliates · Contact · Jobs · Terms & Conditions · Privacy Policy · Documentation · Downloads · Useful Plugins · My Account

Share