if Affiliate Partner is logged 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


Comments

3 responses to “if Affiliate Partner is logged in”

  1. antonio Avatar

    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.

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

      1. Perfect, thanks for sharing !!!
        Cheers

Share