View Full Version : Make 'Referrer' field in registration UNeditable if from 'referrerid' in URL

17 Nov 2005, 05:17

If you'd like to make the 'Referrer' field username UNEDITABLE if a link is followed in a referral URL, here is a solution WITHOUT hacking the 'register.php' file.
(ref: http://www.vbulletin.com/forum/showthread.php?t=132386)

STEP 1: In 'Plugin Manager', assign this new plugin a 'Hook Location' of 'register_form_complete' and give it a 'Title'. You'll then create an arbitrary variable and the conditional statements in which its value will be assigned by doing the following:

Add in the 'Plugin PHP Code' text area this code:
if (empty($referrername)) {$ref_var = 0;}
else {$ref_var = 1;}Make this plugin 'Active'.

STEP 2: In the 'register' template,

Find this code:
<if condition="$show['referrer']">
Modify to this code:
<if condition="$show['referrer'] && $ref_var == 0">
STEP 3: Find its closing tag a few lines below the line mentioned above in STEP 2:
Above it...

Add this code:
<else />
<input type="hidden" name="referrername" value="$referrername" />
That's it.

In summary, if there is no referrerid on the URL OR if it is but it doesn't match a username in the database, the $referrername var will be empty and therefore, the $ref_var will be assigned the value of '0' whereby the 'Referrer' field in the Registration Form will be visible for manual entry. If the username is found in the database, the 'Referrer' field will not be shown but its data in the form of the username found will be sent to the server upon form submission so that username gets the credit for the new member.


P.S. Note: My assessment is, once the referrerid is accepted by the software after locating the username in the database, the information is saved in a cookie even if registration is not completed in that session. Therefore, even when all browser windows are closed and PC is turned off, the next time the Registration Form is loaded, that field will be 'hidden' from the form and 'UNeditable'. Once the form is submitted, that credit will be given to that 'username'.

Bottom line: IF YOU'RE USING A SHARED COMPUTER, you may need to remove that 'bbreferrerid' cookie from your computer manually or the credit to that username will be coming from someone else who's registering and who may not have used a 'referred' URL. I'll leave those cookie-removal steps to others to explain.

17 Nov 2005, 22:00
Thanks for this. Really useful for my forums.

18 Nov 2005, 00:06
I'm glad to hear it.

The whole premise is to put into place, more ways to make the referrer stats more 'tamper-proof.'

Kinda a Part II to this is that which was mentioned in the 'Bottom Line' of the post for SHARED COMPUTER users. That's why I created another thread (http://www.vbulletin.org/forum/showthread.php?t=101027) to begin trying to address the 'bbreferrerid' cookie feature.

Currently, I'm not sure if/how this should be addressed. I hope to get some feedback. In the meantime, I am using this code mod regardless since it addresses the majority of the concern mentioned in the thread referenced at the beginning of the code mod. The rest I'll worry more about as time goes on...

If the 'bbreferrerid' cookie has an expiration, then this would be essentially a non-issue. But the flip side of this is, if a person couldn't finish their registration in that period in which the cookie is 'active', they may not necessarily use the initial URL with referrerid and it becomes a wash, anyway... :squareeyed:

In essence, this whole cookie concern may be a non-issue -- for some, 'so what if the stats are off 2 out of 200'...

I hope to get more feedback about the code mod as well as from those who know more about the infamous 'vb referrer cookie', because I don't know enough about it. :lick:

Take care.

18 Nov 2005, 21:11
Thank you for this!!

18 Nov 2005, 21:20
it can be done without plugins as well (this mod hides the referer field instead of disabling it):