If is_affiliate template tag

Posted in

Hi! I’m setting up a cool affiliate hub and it involves a whole page template. I want the page to be able to tell if users are affiliates or not, but I can’t do it in the template with your shortcodes. Please what is the right conditional to use to find out if someone is or is not an affiliate?

ie.

if(is_affilliate()) { do this }

Thanks!

4 Responses to If is_affiliate template tag

  1. Ansley January 29, 2016 at 7:32 pm #

    That worked! Thank you very much

  2. Ansley January 29, 2016 at 7:06 pm #

    That does not seem to work.

    • Kento January 29, 2016 at 7:19 pm #

      Hi,

      Sorry to interfere with Antonio, but there is a syntax error in the example … anyhow, this is how the shortcode [affiliates_is_affiliate] does it and it’s using a more appropriate API function:

      if ( affiliates_user_is_affiliate( get_current_user_id() ) ) {
      // do stuff
      }

      Cheers

  3. antonio January 29, 2016 at 5:11 am #

    Hi Ansley,
    If you are using directly PHP, you can not use the shortcode. If you need to check if an user is an affiliate, you can use the ‘affiliates_get_user_affiliate’ function. Something like this:
    $user_id = get_current_user_id();
    $affiliate_ids = affiliates_get_user_affiliate( $user_id );
    if ( $affiliates_ids !== null ) {
    ....
    }

    Kind Regards,
    Antonio B.

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