- Author was Featured
- Bought between 10 and 49 items
- Contributed a Blog Post
- Exclusive Author
- Germany
- Has been a member for 3-4 years
- Item was Featured
- Referred between 100 and 199 users
Ok, but for me its not working. I can select the Purchasecode method in the dashboard, but when I go to the register form for the users I dont see any additional input field that I add in the registerpurchasecode.php, which is located in the same folder as the other register php files.
When I select the purchase code option and save it, it still use the registerbasic.php. I test it on my local machine, maybe that why its not working?!
I’ve got the same problem as radykal.
Latest build is 2.0.18.1
Contact x00 at vanillaForums.org he my be interested doing this as a paid mod
Good stuff. Thank you!
I know this is an old thread, but I’m currently making my own support forum and the code posted earlier in the thread doesn’t work anymore with Vanilla’s current version. Using the original code as an inspiration, I made a few changes and it now works. Woot!
First off, I removed the new registration method and stuck with the basic (aka. recaptcha) registration method instead and modified the core scripts for that one.
Here’re the changes I made:
1. In the script applications/dashboard/controllers/class.entrycontroller.php, modify the private function RegisterCaptcha.. add this code right after the first IF statement:
$this->InvitationCode = $this->Form->GetValue('InvitationCode');
$verify = $this->verifyPurchasecode($this->InvitationCode);
if(!$verify['success']){
$this->UserModel->Validation->AddValidationResult('InvitationCode', T('The provided purchase code is invalid.'));
}
2. Append this function to the end of the entry controller class (same file as above):
private function verifyPurchasecode($purchasecode) {
$username = 'ENVATO_USERNAME'; // authors username
$api_key = 'ENVATO_API_KEY'; // api key from my account area
$url = "http://marketplace.envato.com/api/edge/$username/$api_key/verify-purchase:$purchasecode.json";
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$json_res = curl_exec($ch);
$data = json_decode($json_res,true);
if(!empty($data['verify-purchase'])){
$data['verify-purchase']['success'] = true;
}else{
$data['verify-purchase']['success'] = false;
}
return $data['verify-purchase'];
}
3. Edit the registration view script (or create a new theme then create a registration view script there): applications/dashboard/views/entry/registercaptcha.php and add the necessary input in the form:
<li>
<?php
echo $this->Form->Label('Purchase Code', 'InvitationCode');
echo $this->Form->TextBox('InvitationCode', array('value' => $this->InvitationCode));
?>
</li>
This works for me in version 2.0.18.2
You’ll have to tailor the registration fields to what you want afterwards 
Hi Bfintal, thanks for this code for the most recent VF version. I will try it out today and let you know if I get it running.
Best Regards, Oisin
Cool! Just for reference, here’s my forum where I got it working: http://support.gambit.ph/entry/register
bfintal said
Cool! Just for reference, here’s my forum where I got it working: http://support.gambit.ph/entry/register
Awesome!! Thanks!! Will definitly replace my phpBB3 forum with vanilla and your awesome code.
phpBB3 is better but it cannot have Envato verification code and it’s tooooo BIG to manage.
hey all is it possible to direct me to a wordpress modification so users can register only by the purchase code? I have the api and the file buy I need a little help implementing it and testing it?
Thanks in advance
Hi,
If you want a wordpress solution, i recommend you search on codecanyon were you will find an awesome plugin created for the envator authors ( i don’t want to give direct link because i am not allowed
).
Best regards, Stefan
