SHARE
TWEET

Affiliates by @itthinx : get_affiliate_id

a guest Jun 30th, 2014 218 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static function get_affiliate_id ( ) {
  2.         global $wpdb;
  3.                
  4.         $pname = get_option( 'aff_pname', AFFILIATES_PNAME );
  5.                
  6.         $affiliate_id = "";
  7.         $user_id = get_current_user_id();
  8.         if ( $user_id && affiliates_user_is_affiliate( $user_id ) ) {
  9.                 $affiliates_table = _affiliates_get_tablename( 'affiliates' );
  10.                 $affiliates_users_table = _affiliates_get_tablename( 'affiliates_users' );
  11.                 if ( $affiliate_id = $wpdb->get_var( $wpdb->prepare(
  12.                         "SELECT $affiliates_users_table.affiliate_id FROM $affiliates_users_table LEFT JOIN $affiliates_table ON $affiliates_users_table.affiliate_id = $affiliates_table.affiliate_id WHERE $affiliates_users_table.user_id = %d AND $affiliates_table.status = 'active'",
  13.                         intval( $user_id )
  14.                 ))) {
  15.                         $affiliate_id = affiliates_encode_affiliate_id( $affiliate_id );
  16.                 }
  17.         }
  18.         return $affiliate_id;
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top