PDA

View Full Version : Programatticaly Control UserGroup on Registration


chrymo
09-02-2011, 10:03 AM
Hi, Is there a "Safe" and proper way to do the ff?:

www.mysite.com/registerfree.php -------------------> Registers only "Free" Usergroup
www.mysite.com/registerpremium.php -------------> Registers "Premium" Usergroup
www.mysite.com/registerplatinum.php--------------> Registers "Platinum" Usergroup
and so on...

Like having separate register.php file for each usergroup.

Please point me into the right direction, since Ive been searching for almost 48 hours now total and I couldnt find any info on how to do this.

Thanks!

kh99
09-02-2011, 12:42 PM
So you want new users to go to different user groups depending on which form they fill out? I don't know if I know the "right" way to do it, but if you create a plugin using hook location register_addmember_process you can set $newusergroupid to the user group you want to put the new user in, if you are not using email verification. If you are using email verification, you can check using hook location register_addmember_complete and change the useractivation table so that the user will be put in the desired user group on activation.

So, at register_addmember_process

if(!$vbulletin->options['verifyemail'])
{
// do some check to figure out usergroupid (X)
$newusergroupid = X;
}


and/or at register_addmember_complete

if(!$vbulletin->options['verifyemail'])
{
// do some check to figure out usergroupid (X)
$newusergroupid = X;
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "useractivation
SET usergroupid = '".$newusergroupid."'
WHERE activationid = '".$activateid."' LIMIT 1 ");
}


As far as what to check, I'm not sure, but I'd recommend against simply putting a usergroupid field or other hidden field in the registration form, since a user can change that pretty easily. You'd have to do something like check how much they've actually paid (assuming they're paying), or some other thing that they can't fake by changing the submitted form data.

Anyway, I hope this at least begins to answer your question. And thanks to user ForumsMods mod here: https://vborg.vbsupport.ru/showthread.php?t=188684 where I pretty much got the above hooks and code from.

chrymo
09-03-2011, 03:15 AM
Yes, Pretty Much you got it right, I am concerned however of editing the register.php file to achieve this, as for the hooks, applying them with checks is the best bet, but I am finding out a way to implement these as easily as I could.

I dont want to let visitors choose usergroups on registration or hiding form elements to implement this.

My process will go something like:

User Arrives at a Sales Page for example like www.mysalespage.com and part of the package they pay there is membership to my forum with a unique subforum for people who bought the product on my salespage.

It will be difficult to integrate my payout system for example that once they fill up info on my sales page, they will be also added to my forum, so I opted to have them re-register to the forum for separate database, and have them register to this unique page where they are automatically assigned to their usergroup.

That is why I am asking if there is an easier better way to handle what I need VB to do...

chrymo
09-05-2011, 03:53 AM
No More Thoughts on the Matter?

chrymo
09-29-2011, 10:59 AM
Also guys please check my other posts pertaining to the matter, I'd be willing to listen to any paid proposals or whatnot as long as I get the result I want. Thanks