Referrer Affiliate User ID

I am making use of the “Affiliates is Referred” plugin recommended in /useful-plugins/. The reason I am using it is to create a landing page for the visitor to see customized information about the affiliate who referred them. One of the elements I want to show on the page is a profile picture of the affiliate. I have added images to the affiliate profile, but I am having issues getting the actual user id.

Using the short code [referrer_user display=”referrer_id”] produces the login name. Using the short code [referrer_id] produces their token for the URL.

Is there a short code for the actual ID as found in the wp_users table?
Better yet, is there someone already using a customized landing page for visitors showing their referring affiliate’s information?


Comments

3 responses to “Referrer Affiliate User ID”

  1. Hi,

    I would recommend to get the user ID of the referring affiliate directly through the API, this makes it easier to work with:

    require_once( 'class-affiliates-service.php' );
    $affiliate_id = Affiliates_Service::get_referrer_id();
    if ( $affiliate_id ) {
        $user_id = affiliates_get_affiliate_user( $affiliate_id );
        // @todo do stuff ...
    }
    

    With that, you first check if the visitor has been referred, obtaining the affiliate ID and then get the user ID for the affiliate.

    I hope that helps, let me know if you need further help please.

    1. Hi Kento,

      Thank you. This worked for me. What I ended up doing was adding it to the class for the “Affiliates is Referred” plugin and adding a short code for it.

      For anyone else looking for the same solution, install the affiliates-is-referred plugin from the github repository. In the init function at the top, add this line:
      add_shortcode( ‘affiliates_is_referred_id’, array( __CLASS__, ‘is_referred_id_func’ ) );

      Then inside the class add this function:

      public static function is_referred_id_func(){
      require_once AFFILIATES_CORE_LIB . ‘/class-affiliates-service.php’;
      if ( $referrer_id = Affiliates_Service::get_referrer_id() ) {
      if ( $referrer_id ) {
      $user_id = affiliates_get_affiliate_user( $referrer_id );
      return $user_id;
      } else {
      return false;
      }
      } else {
      return false;
      }
      }

      Thanks for your help!!

      1. Thanks Sean,
        you also have available Affiliates-Popup file in github.
        cheers

Share