WordPress Affiliate Manager

Affiliates Management Plugin for WordPress

  • Home
  • Features
    • Screen Shots
  • Download
  • Documentation
  • Addons
  • Support
    • Support Forum
    • Forum Login
    • Forum Registration
    • Contact
    • Premium Addon/Plugin Support

Get Affiliate's Username by their Affiliate ID/RefKey

by

WordPress Affiliate Manager › Forums › Affiliate Manager Plugin › Get Affiliate's Username by their Affiliate ID/RefKey

Tagged: affiliate id, get, invite code, paid membership pro, refkey, username

  • This topic has 16 replies, 2 voices, and was last updated 10 years, 10 months ago by admin.
Viewing 2 posts - 16 through 17 (of 17 total)
← 1 2
  • Author
    Posts
  • October 29, 2014 at 8:45 am #348
    christianf3
    Participant

    I took a look at lines 225-266 of affiliate-manager/source/Tracking/RequestTracker.php and I found this:

    			$refKey = new WPAM_Tracking_TrackingKey();
    			$refKey->unpack( $strRefKey );
                            
    			$db = new WPAM_Data_DataAccess();
    			$affiliateRepos = $db->getAffiliateRepository();
    			$affiliateId = $affiliateRepos->getAffiliateIdFromRefKey( $refKey->getAffiliateRefKey() );
    
    			if ( $affiliateId === NULL ) {
    				echo '<pre>Affiliate ID: ';
    				var_export($affiliateId);
    				echo "\n\n";
    				echo $refKey;
    				throw new Exception( __( 'invalid refkey data.', 'wpam' ) );
    			}
    
    			//#37 make sure the affiliate is active before tracking stats
    			$affiliate = $affiliateRepos->load( $affiliateId );
    			if ( ! $affiliate->isActive() )
    				return;
    
    			$idGenerator = new WPAM_Tracking_UniqueIdGenerator();
    			$trackTokenModel = new WPAM_Data_Models_TrackingTokenModel();
    
    			$trackTokenModel->dateCreated = time();
    			$trackTokenModel->sourceAffiliateId = $affiliateId;
    			$trackTokenModel->sourceCreativeId = $refKey->getCreativeId();
    			$trackTokenModel->trackingKey = $idGenerator->generateId();
    			$trackTokenModel->referer = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : NULL;
    
    			if ( isset( $request['wpam_affiliateSubCode'] ) ) {
    				$trackTokenModel->affiliateSubCode = $request['wpam_affiliateSubCode'];
    			}
    
    			$db->getTrackingTokenRepository()->insert( $trackTokenModel );
    			$db->getEventRepository()->quickInsert( time(), $trackTokenModel->trackingKey, 'visit' );
    
    			$binConverter = new WPAM_Util_BinConverter();
    			// store the tracking key in a cookie so we can monitor their activities
    			$return = setcookie( WPAM_PluginConfig::$RefKey,
    								 $binConverter->binToString( $trackTokenModel->trackingKey ),
    								 $this->getExpireTime(),
    								 COOKIEPATH );

    Am I on the right track with this code for setting the tracking cookie?

    October 29, 2014 at 11:36 pm #349
    admin
    Keymaster

    Yeah, that code should be a good example for you.

  • Author
    Posts
Viewing 2 posts - 16 through 17 (of 17 total)
← 1 2
  • You must be logged in to reply to this topic.
Log In

Featured Addons

  • WooCommerce Coupon Tracking
  • WooCommerce Product Specific Commission

Copyright © 2025 | WordPress Affiliate Manager | Privacy Policy