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
You are here: Home

christianf3

  • Profile
  • Topics Started
  • Replies Created
  • Engagements
  • Favorites

Forum Replies Created

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • October 29, 2014 at 8:45 am in reply to: Get Affiliate's Username by their Affiliate ID/RefKey #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 24, 2014 at 2:11 pm in reply to: Get Affiliate's Username by their Affiliate ID/RefKey #343
    christianf3
    Participant

    Thanks, that’s EXACTLY what I needed!

    So far, I’m halfway finished. (The affiliate’s invite code is automatically added into the PM Pro registration form field when an affiliate’s cookie is detected)

    Now I’m working on the other half. (Using only the invite code to set the affiliate cookie) I’ve finished writing the code that pulls the affiliate record based on the invite code entered. Now I just need a way to set the affiliate cookie.

    Can you please provide me with a code snippet that will allow me to set the affiliate cookie?

    Thanks again

    October 20, 2014 at 7:04 am in reply to: Get Affiliate's Username by their Affiliate ID/RefKey #333
    christianf3
    Participant

    Thanks for the response. I’m still a bit unclear. . .

    Can you give me some example code that will query the affiliate’s table to get the AID using that user’s email?

    Once I know the right way to query the affiliate’s table, I’ll be able to change it to get the other values I need.

    October 17, 2014 at 6:59 am in reply to: Get Affiliate's Username by their Affiliate ID/RefKey #326
    christianf3
    Participant

    Well, the affiliate’s email address in PM Pro/wordpress may be totally different from the one the user used to signup to become an affiliate.

    I’m wondering how to get the AID of the referring affiliate from the database by using the refkey value passed in the url or via a cookie during signup?

    Then, how can I use the AID to get the userId of the affiliate? (I need this user id to get the user’s invite code from the wordpress usermeta table)

    Lastly, how can I get the AID of the affiliate using their userId? (This will allow me to use the code you provided to get and assign the refkey)

    I just need to know how to pull this data from the database, and I can take care of the rest.

    October 16, 2014 at 5:18 am in reply to: Get Affiliate's Username by their Affiliate ID/RefKey #323
    christianf3
    Participant

    Hi, any thoughts on this?
    So far WP Affiliate Manager is exactly what I’m looking for, but my system requires that I have this invite code system connected to the affiliate system, and I at least need to know how to query the database for the affiliate’s info to get this to work for me. I am on a timeline with this project, and I just want to know if what I want to do is at all possible, or if I need to start looking into other options.

    Thanks

    October 11, 2014 at 1:23 pm in reply to: Get Affiliate's Username by their Affiliate ID/RefKey #319
    christianf3
    Participant

    Thanks, that explains how to get the refkey. Now, my only challenge is getting the affiliate’s id.

    What about the getAffiliateIdFromRefKey() function? Is there a way to use this function to get the affiliate’s id by passing the $strRefKey (which could contain either $_COOKIE[WPAM_PluginConfig::$RefKey], or $request[WPAM_PluginConfig::$RefKey]) variable into it?

    Once I have the affiliate’s id, I just need a way to get their wordpress user id from the Affiliate Repository, so that I can use it to get their invite code via get_user_meta(). Is it possible to query the database for the affiliate’s user id using the affiliate id? I see that the data is stored in the wpam_affiliates table, but I haven’t been able to successfully pull it.

    October 10, 2014 at 10:14 am in reply to: Get Affiliate's Username by their Affiliate ID/RefKey #314
    christianf3
    Participant

    When you say that you can get the refkey using their ID, do you mean their wordpress user id, or their affiliate id? And what’s the best way to get the affiliate’s refkey by their ID?

    October 9, 2014 at 6:25 pm in reply to: Get Affiliate's Username by their Affiliate ID/RefKey #309
    christianf3
    Participant

    I managed to find a hidden PM Pro Invite Only Addon which has saved me many hours of development time. So now, I’m in the process of modifying the WP Affiliate Manager – PM Pro Integration plugin to do 2 things:

    1) Automatically add the referring affiliate’s Invite Code during registration.

    2) If no refkey is set, automatically set the refkey based on the invite code of the referring affiliate.

    I have all of the code written out to execute this logic already, and I’m in the debug process. The only problem I’m having is with the SQL Queries that pull the affiliate’s data.

    This is what my queries look like:

    		//get affiliate's user id if there is an affiliate refkey - NEED TO FIX THIS QUERY
    		$aff_user_id = $db->get_var( $db->prepare( "SELECT userId FROM {$db->$affiliates_table} WHERE meta_key = 'uniqueRefKey' AND meta_value='%s'", $affiliate_code ) );
    		//get affiliate's user id by the invite code	
    		$aff_user_id = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = 'pmpro_invite_code' AND meta_value='%s'", $affiliate_code ) );
    		//get affiliate's refkey by affiliate's user id
    		$aff_RefKey = $wpdb->get_var( $wpdb->prepare( "SELECT uniqueRefKey FROM {$wpdb->wpam_affiliates} WHERE meta_key = 'userId' AND meta_value='%s'", $aff_user_id ) );

    Is there a special way that I need to access the data from the affiliate repository so that I can get the affiliate’s user id by their refkey and get their refkey by their user id?

    I’m excited about getting this done to contribute to making this plugin even better. Thanks again.

    October 8, 2014 at 10:19 am in reply to: Tracking Paid Membership Pro FREE Signups #304
    christianf3
    Participant

    I see what you mean, but I definitely think it’s important to keep track of free referral signups so that you and your affiliates can track conversion rates as free members upgrade. On another note, I think WP Affiliate Manager would really stand out from the other competing affiliate plugins if it offered a multi-level affiliate program, and I think the ability to link the referring affiliate to members (sub-affiliates) will play a key role in that.

    I do believe that this plugin offers one of the most professional affiliate systems I’ve seen on wordpress. And I want to contribute some code to this plugin, once I get an idea of how all of the pieces fit together.

    Keep up the good work guys.

    October 8, 2014 at 9:40 am in reply to: Get Affiliate's Username by their Affiliate ID/RefKey #303
    christianf3
    Participant

    Excellent! Nice work.

    I must say, the affiliate’s username is still the best case scenario, because it’s not too short like the Affiliate ID, and it’s not too long like the encrypted refkey string. My goal is to use the refkey as an invite code that is required to register for my site, and ultimately I would like to be able to use these codes in printed media as well.

    Any suggestions on how I can generate a username-based invite code off of the affiliate’s ID or encrypted refkey?

    Many thanks for your help with this.

    September 30, 2014 at 2:09 am in reply to: How to Integrate with Paid Membership Pro #275
    christianf3
    Participant

    I do see the default commission rate set for my user, but I have 3 memberships setup in Paid Membership Pro:
    1) Free ($0 per sale – no commission should be given)
    2) Paid ($1 per sale)
    3) Premium ($5 per sale)

    I really need some way of setting the commission for each membership type that is being sold. That’s what I thought the PM Pro Integration plugin would do. Is there a way to do this?

    I also see the affiliate’s link in the creatives section of their profile and their referral key looks like this: http://teamupmovement.com/?wpam_refkey=F,G8Vb4OMU7nioeqcKp3Now6Ger00000000000.

    How can I shorten this wpam_refkey value to simply use the affiliate’s username like this:
    http://teamupmovement.com/?wpam_refkey=mmckenzie

    I really think this would make things much easier the affiliates to use, and for site visitors and new customers as well.

    And one last question. How do I view my affiliate account as an admin user? When I’m logged in as admin and I visit the Affiliate Login page, it says “You are currently logged in”, but when I visit the Store Affiliates page, it asks me to apply (register). Then, I tried registering while logged in as admin, and it created the affiliate on the My Affiliates list, but the same thing happens on the Affiliate Login and Store Affiliates pages.

    Thanks for getting back to me on this, I really appreciate it.

  • Author
    Posts
Viewing 11 posts - 1 through 11 (of 11 total)

Featured Addons

  • WooCommerce Coupon Tracking
  • WooCommerce Product Specific Commission

Copyright © 2026 | WordPress Affiliate Manager | Privacy Policy