PDA

View Full Version : Add User to Primary Usergroup Based on Value of Custom Profile Field


amykhar
06-12-2005, 10:00 PM
This version is for the PRIMARY group. Here is the one for secondary groups:

https://vborg.vbsupport.ru/showthread.php?t=82993

As far as plugins goes, this one is an advanced plugin because you WILL need to make some tweaks to suit your needs.

What this plugin does: If you have a custom profile field, for example one for gender, it checks to see if the user has selected a specific value and then assigns them to a primary user group based on that selection. This happens at the time the user activates their email account after registering.

Instructions for installation:
A. Create your custom profile field and make a note of the field number. (Or simply make a note of the field number of an existing field.)

B. Make a note of the value you are checking for. For example, you may be looking to see if your member selected "male" in your custom gender field.

C. Make a note of the usergroup number that you want to set the user to.

D. Here you have two options:
Option 1: Edit the attached XML file before you import it to change the field number, the value that you check for and the usergroupid. In my XML file, I am checking field5 to see if the value is yes and changing the usergroup to 10.


<?xml version="1.0" encoding="ISO-8859-1"?>

<plugins>
<plugin active="1" product="vbulletin">
<title>Put User In User Group Based on Field Value</title>
<hookname>register_activate_process</hookname>
<phpcode><![CDATA[// Get the value for field 5
$user = $db->query_first("
SELECT field5
FROM " . TABLE_PREFIX . "userfield
WHERE userid = " . $vbulletin->userinfo['userid'] . "
");


if ($user['field5'] == 'yes')
{
$userdata->set('usergroupid', 10);
}]]></phpcode>
</plugin>
</plugins>



If, for example, you want to check the value of field6, change field5 in the XML file to field6. If you are looking for "male" instead of "yes", change

if ($user['field5'] == 'yes')


to:


if ($user['field5'] == 'male')


And, finally, change the usergroup as appropriate. Instead of 10 in this line:

$userdata->set('usergroupid', 10);


substiture your usergroupid of choice.

Option 2: Import the XML file as is, open the plugin manager, and make your edits there.


NOTE: This mod works for forums that require users to verify their email address upon registration. If your forum does not require users to verify their email address, you will need to use a different hook. If I have time, I'll test that variation.

Amy

Brinnie
07-15-2005, 04:22 AM
Hello, I cannot seem to find the alternate "female" option in your code examples.

How does one go about adding that?

Brinnie
07-15-2005, 04:58 AM
Hello, I just installed it and and it didn't work! :(

I registered a test account and chose the option "male" as directed in the in instructions, but it stayed in the same group :(

I uploaded this XML:
<?xml version="1.0" encoding="ISO-8859-1"?>

<plugins>
<plugin active="1" product="vbulletin">
<title>Put User In User Group Based on Field Value</title>


<hookname>register_activate_process</hookname>
<phpcode><![CDATA[// Get the value for field 5
$user = $db->query_first("
SELECT field5
FROM " . TABLE_PREFIX . "userfield
WHERE userid = " . $vbulletin->userinfo['userid'] . "
");


if ($user['field5'] == 'male')
{
$userdata->set('usergroupid', 12);
}]]></phpcode>
</plugin>
</plugins>


Does it make a difference if I use radio buttons?
Please help :(

Brinnie
07-15-2005, 06:20 AM
please help. :(

Brad
07-15-2005, 09:28 AM
There is no need to bump a thread so many times in such a short time peroid.

Did you create a new custom profile field via the admin cp?

http://www.vbulletin.com/docs/html/profile_introduction

Brinnie
07-15-2005, 11:41 AM
There is no need to bump a thread so many times in such a short time peroid.

Did you create a new custom profile field via the admin cp?

http://www.vbulletin.com/docs/html/profile_introduction

Yes sir, I did. I used radio buttons. set one to male, set one to female and made it required on registration.

Anything else I could have missed?

amykhar
07-15-2005, 12:36 PM
Make sure you have it case sensitive. Make sure you get the right field number and make sure you have the right user group number.

Brinnie
07-15-2005, 07:57 PM
Make sure you have it case sensitive. Make sure you get the right field number and make sure you have the right user group number.

yes, it's field number 5, my first custom field.
yes, case is correct.
and im quite sure usergroup 12 is the one I want them to be added to.
the customized usergroup1.xml I posted was exactely what I uploaded into the plugins.

I do not understand why it does not work. Might it be related to the idea that there is no secondary "female" option in your example script?

amykhar
07-15-2005, 08:11 PM
Brinnie, you have to remember 3.5 is beta software. It's working on my test board and my live board. Nobody else has complained that it doesn't work. I don't know why it's not working for you.

And given that you've changed the copyright in your footer, I can't see what version of the beta you are using.
p.s. I'm not entirely certain that your copyright is kosher according to the vbulletin license.

Brinnie
07-16-2005, 04:44 PM
Brinnie, you have to remember 3.5 is beta software. It's working on my test board and my live board. Nobody else has complained that it doesn't work. I don't know why it's not working for you.

And given that you've changed the copyright in your footer, I can't see what version of the beta you are using.
p.s. I'm not entirely certain that your copyright is kosher according to the vbulletin license.

Amy,

it's a beta 4.
but, i don't want the words "beta" anywhere on my site, so I pwnd it.

Christine
07-16-2005, 04:52 PM
Brinnie,

Unless you paid for copyright removal, at the least, the copyright needs to read:

vBulletin, Copyright ?2000 - 2005, Jelsoft Enterprises Ltd.

You don't have to keep version information, but the rest is required by Jelsoft.

:)

Brinnie
07-17-2005, 06:57 AM
Brinnie,

Unless you paid for copyright removal, at the least, the copyright needs to read:

vBulletin, Copyright ?2000 - 2005, Jelsoft Enterprises Ltd.

You don't have to keep version information, but the rest is required by Jelsoft.

:)
oh well, that's jelsofts problem.
I'm buying the full version next week, so...

anyone have sucess with this on Beta 4?

Marco van Herwaarden
07-17-2005, 07:07 AM
oh well, that's jelsofts problem.
I'm buying the full version next week, so...

anyone have sucess with this on Beta 4?Wrong this is your problem. You must follow your license agreement.

Brinnie
07-17-2005, 07:09 AM
Wrong this is your problem. You must follow your license agreement.of course...

amykhar
07-17-2005, 03:07 PM
oh well, that's jelsofts problem.
I'm buying the full version next week, so...

anyone have sucess with this on Beta 4?

It's running fine for me on Beta 4.

akanevsky
08-01-2005, 08:16 PM
I don't think you need the select query. I mean, the custom fields get passed on by the POST method. They should already be somewhere in the script. Get the values from there.

amykhar
08-02-2005, 02:03 PM
You would think so, wouldn't you. But, if you look at the code, you'll see that what's passed in to the activation routine are two things: The username and the activation id.

Using the username, the code gets the userinfo BUT not all of it. It only gets what's in the user table. It doesn't get the profile fields. And, it never does a call to fetch_userinfo(). (Which would result in a query as well.)

If I weren't doing this as a plugin, I would have changed the query to do a left join and get the profile field stuff. But, I'm doing this as a plugin and can't change the query. Hence, the second query.

Amy

akanevsky
08-02-2005, 02:17 PM
Ah... Sorry, I did not notice that you were hooking it into the activation section. I thought you added the group right upon registration... :P

amykhar
08-02-2005, 02:22 PM
Nope. I don't want unactivated users in secondary user groups.

I figured it was safer this way for all concerned because not everybody understands how secondary usergroup permissions work. They could end up with some nasty surprises by putting somebody in a secondary usergroup that has priv to post, view attachments, or whatever.

Yes, the answer is to severely limit secondary groups, but not everybody knows to do that. :)

Amy

justindwhite
10-07-2005, 12:02 AM
I am getting a Parse error when the user tries to activate their account. Here is the plugin I used. Is everything OK? Anyone know the problem?

<?xml version="1.0" encoding="ISO-8859-1"?>

<plugins>
<plugin active="1" product="vbulletin">
<title>Put User In User Group Based on Clan Signup</title>
<hookname>register_activate_process</hookname>
<phpcode><![CDATA[// Get the value for field 9
$user = $db->query_first("
SELECT field9
FROM " . TABLE_PREFIX . "userfield
WHERE userid = " . $vbulletin->userinfo['userid'] . "
");


if ($user['field9'] == 'OnLineRegulator')
{
$userdata->set('usergroupid', 11);

if ($user['field9'] == 'OLR')
{
$userdata->set('usergroupid', 10);

if ($user['field9'] == 'OLR ANZACs')
{
$userdata->set('usergroupid', 19);

if ($user['field9'] == 'OLR Canada')
{
$userdata->set('usergroupid', 20);

if ($user['field9'] == 'OLR Divas')
{
$userdata->set('usergroupid', 12);

if ($user['field9'] == 'OLR Elite')
{
$userdata->set('usergroupid', 13);

if ($user['field9'] == 'OLR GreatBritain')
{
$userdata->set('usergroupid', 25);

if ($user['field9'] == 'OLR Holland')
{
$userdata->set('usergroupid', 22);

if ($user['field9'] == 'OLR Spartan')
{
$userdata->set('usergroupid', 9);

if ($user['field9'] == 'OLR United States')
{
$userdata->set('usergroupid', 24);

if ($user['field9'] == 'OLR Coalition')
{
$userdata->set('usergroupid', 39);

if ($user['field9'] == 'OLR Honorary Member')
{
$userdata->set('usergroupid', 38);

if ($user['field9'] == 'Not A Member')
{
$userdata->set('usergroupid', 16);

}]]></phpcode>
</plugin>
</plugins>

TheElf
10-17-2005, 07:52 PM
Yes sir, I did. I used radio buttons. set one to male, set one to female and made it required on registration.

Anything else I could have missed?

The whole plugin system is disabled by default, have you enabled it?

amykhar
10-18-2005, 12:27 AM
Not going to get a response from that user. She was banned.

rookiyong
10-29-2005, 02:41 AM
Hi amykhar, if anytime after registration, a user changes the profile field from A to B, will the primary usergroup of that user also change without any approval from the admin side?

I am looking for something that allows a user to change usergroup without the need to wait for approval :)

amykhar
10-29-2005, 03:29 AM
No. It will not change. This affects registrations only. All you have to do with regards to the no approval needed is to not set up a group leader.

rookiyong
10-29-2005, 03:42 AM
Great! Thanks, and I will still have use for your hack. :)

CyberRanger
11-04-2005, 11:49 AM
Before I dig into your code, off the top of your head, do you think I can modify this so that the primary usergroup is set based on the email domain? I have users from a certain domain (my work) who I want to have automatically moved into a primary usergroup with greater permissions. Thanks!

mindfrost82
11-04-2005, 02:10 PM
I know that Brinnie is banned, but if anyone else is having a problem like her's, make sure that

if ($user['field5'] == 'yes')

is case sensitive. I kept it at 'yes' when my option was 'Yes' and it wouldn't work.

I think Amy said that somewhere in here too.

lazyseller
11-08-2005, 06:36 PM
I have an idea for cobranding but unsure how to implement this

is there a way to set usergroup based on $styleid ?

for example if styleid = 2 usergroup will be 10 ?

Any help would be appreciated

amykhar
11-08-2005, 06:40 PM
It sounds like if a user registers from one domain, you want them to see one style and one set of forums and if they register from another domain, you want them to see a different style and set of forums. Is that what you are going for?

Amy

silly rabbit
11-08-2005, 07:01 PM
Not going to get a response from that user. She was banned.

Good Move!! amykhar, this is very cool - I like it, am convinced it will work and will use it but haven't installed it yet.

Have quick 2 Qs 1'st to ensure I get it right - am new to php/HTML but if I want to divide new regs into one of three different employee groups based on senority date(ie: less than 5 yrs, 5 - 15yrs and 15yrs+)? Q1 -> whats the HTML/PHP 'format' entry to ensure date entered is in correct format of '122505'(Christmas day)?? Q2 -> is this 'doable' here for me??

Thx In advance,

Rabbit

amykhar
11-08-2005, 07:05 PM
Nobody has seniority at registration time, so no. This mod can't help you. You can use the built in promotion system, I believe.

Amy

silly rabbit
11-08-2005, 07:23 PM
Nobody has seniority at registration time . . .

Amykhar, already have 'senority' as a required 'custom' field upon registration?? Granted don't have 'input verification' yet . . .

Marry Me? Rabbit (with respect)

amykhar
11-08-2005, 07:25 PM
Doh. Sorry for my stupid initial response. Let me look at it a bit and get back to you. I'm multitasking right now.

silly rabbit
11-08-2005, 07:28 PM
Let me look at it a bit and get back to you. I'm multitasking right now. . . .

No Problem!!!

You can use the built in promotion system

I'm Not READING either - need to check out as well(if referring to 'posts' have already)

Thx Will Check Back LATER!!

Rabbit

lazyseller
11-08-2005, 07:36 PM
It sounds like if a user registers from one domain, you want them to see one style and one set of forums and if they register from another domain, you want them to see a different style and set of forums. Is that what you are going for?

Amy

Thanks... for responding i have found a solution for this ..

webspider
11-10-2005, 11:47 AM
Nice mod I wondered how to do this.

I'm using this mod to ask the user if they wish to receive the site newsletter or not. This works fine on registration but they can't change their minds. So I added the option and two plugin's for the user to select yes or no on update profile. The problem I'm having is it does not always work I have to select Yes or No and save twice for the plugin to actually do the job of moving the user from one group to the other.

Is there anyway to combine these two options into one and is there a more sure way to ensure that the update actually occurs?

Hook Location profile_updateprofile

// Get the value for field 5
$user = $db->query_first("
SELECT field5
FROM " . TABLE_PREFIX . "userfield
WHERE userid = " . $vbulletin->userinfo['userid'] . "
");
if ($user['field5'] == 'Yes')
{
$userdata->set('usergroupid', 2);
}

AND

// Get the value for field 5
$user = $db->query_first("
SELECT field5
FROM " . TABLE_PREFIX . "userfield
WHERE userid = " . $vbulletin->userinfo['userid'] . "
");
if ($user['field5'] == 'No')
{
$userdata->set('usergroupid', 44);
}

Token55
12-30-2005, 05:24 AM
Hey there,

This is exactly what I want to do, but I'm having a little trouble with it. I'm checking the correct field for the correct value (field6 is populating properly & I'm checking for the right values). It's hooked at the right place, register_activate_process.

I am using vB 3.5.2 - is that the problem? If so, any thoughts on how to get this to work?

Here's the code I'm using:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<plugins>
<plugin active="1" product="vbulletin">
<title>Put User In User Group Based on Field Value</title>
<hookname>register_activate_process</hookname>
<phpcode>
<![CDATA[
// Get the value for field 6
$user = $db->query_first("
SELECT field6
FROM " . TABLE_PREFIX . "userfield
WHERE userid = " . $vbulletin->userinfo['userid'] . "
");


if ($user['field6'] == 'chicago')
{
$userdata->set('usergroupid', 11);
}
if ($user['field6'] == 'cincinnati')
{
$userdata->set('usergroupid', 10);
}
if ($user['field6'] == 'indianapolis')
{
$userdata->set('usergroupid', 9);
}

]]>
</phpcode>
</plugin>
</plugins>

The values for field6 are set up to be all lowercase.

When I click the activation link in the email, a blank window pops up with this address...
http://www.mydomain.com/forums/register.php?a=act&u=15&i=80639843
...but it freezes there. The user gets activated, but is not assigned to the desired usergroup.

Thanks a bunch for any help.

Crrrazzzy
01-24-2006, 11:17 PM
fixed

Valentino
01-29-2006, 05:20 PM
Great plugin Amy!

I'm wondering if you (or any other able person) would help me? I want to use the plugin, but I don't have email verification turned on. What do I need to change to make this work without email verification?

Val

Valentino
02-11-2006, 02:51 PM
Can anyone help me? :)

Valentino
02-14-2006, 05:56 PM
Please... https://vborg.vbsupport.ru/external/2006/02/11.gif

Valentino
02-16-2006, 08:18 PM
C'mon, who do I have to kiss to get some help?

paulfletcher
02-28-2006, 01:28 PM
Can someone help me, I added this plugin to our website (XYZ Training) (http://www.xyztraining.com/index.php) and when clicking on the activation link that is sent automatically to your email account I get a parse error. (See Attachment)

I think I installed the plugin correctly, and I made sure I enter the correct information into the code before I uploaded the xml file. I double checked the group ID, and the usergroup ID. I also verified the contents that will be entered into the text field.

Thanks,
Paul

paulfletcher
03-10-2006, 07:10 PM
Has anyone got this to work on 3.5.4, and would like to help me out?

Thanks,
Paul

amykhar
03-11-2006, 12:50 AM
Paul, it's been running on my board since the early betas and still works on 3.5.4

paulfletcher
03-11-2006, 05:45 AM
Thanks for getting back to me. I wasn't sure if it still worked for 3.5.4. I'm working on an Activation Code text field that would appear during registration. This would allow for a community license to be issued to a school or company (we will be creating video tutorials).

After talking to other users they suggested that I use the secondary usergroup script that you created, this would allow me to easily demote a group of users back to a normal registered usergroup if needed.

Will your primary or secondary script that you created work with text fields? Or only Radio & Check boxes?

Thanks,
Paul

amykhar
03-11-2006, 03:15 PM
text fields will work as well.

trigon
03-31-2006, 10:43 PM
amykhar, you wrote: NOTE: This mod works for forums that require users to verify their email address upon registration. If your forum does not require users to verify their email address, you will need to use a different hook. If I have time, I'll test that variation.
So on my Board i have no email verifycation, can i use this one too, or must i wait until your next variation??
(Btw: I tried but it doesnt go) :(

harmor19
04-05-2006, 12:06 AM
Is it possible to assign an user to an usergroup depending the value of the profile field after they have registered?

Let me explain.
I run a hosting forum and some members don't even use their hosting account.
I send out an email telling that they haven't used their (sub)domain and that need to reply to the email.
After I send the email I edit their profile and select "Warned" from the drop down list. I also have "Suspended" (from the hosting) and "Terminated".

amykhar
04-05-2006, 02:15 PM
It's possible to do it, just not with this mod.

JAV-ISH
04-19-2006, 09:22 PM
If I use moderated public groups, the user is active in this group without moderation. Is there a workaround?

amykhar
04-19-2006, 10:38 PM
what do mean by moderated public group? A group where the leader must approve the members? This mod is not intended to work with such groups.

sepulchres
05-01-2006, 11:30 AM
what do mean by moderated public group? A group where the leader must approve the members? This mod is not intended to work with such groups.
I'm also getting a parse error when I activate the account of the registered user. It seems that a lot of people are getting the same thing when using this hack. I read that Paul was having similar problems and Amy, you fixed it...But that was in the secondary one. Is there anything I can do to fix mine because it seems to be a similar problem that I am having. Cheers.

btw, I have checked all the userids and options of the custom field. I am using custom groups which are not public and emails must be verified by users. Here is the php code from the plugin...

Plugin PHP Code
// Get the value for field 5
$user = $db->query_first("
SELECT field5
FROM " . TABLE_PREFIX . "userfield
WHERE userid = " . $vbulletin->userinfo['userid'] . "
");


if ($user['field5'] == 'Year 9')
{
$userdata->set('usergroupid', 9);

if ($user['field5'] == 'Year 10')
{
$userdata->set('usergroupid', 10);

if ($user['field5'] == 'Year 11')
{
$userdata->set('usergroupid', 11);

if ($user['field5'] == 'Year 12')
{
$userdata->set('usergroupid', 12);
}

paulfletcher
05-01-2006, 12:18 PM
Hey. :) Well It was working for the secondary user-group. Although I found out that I needed one for the primary group. So Amykhar helped me out with this slight modification of the script... Works on my board (3.5.4).

switch($userinfo['field5'])
{
case "A":
$userdata->set('usergroupid', 12);
break;
case "B":
$userdata->set('usergroupid', 13);
break;
case "C":
$userdata->set('usergroupid', 18);
break;
}

Talk to you later,
Paul F

amykhar
05-01-2006, 12:19 PM
Because this mod requires you to change the code for it to work, you really need to be careful when making the changes. You haven't closed the braces on your first three if clauses, which is what's giving you the parse errors. I'm sorry, but I can't keep fixing these problems on an individual basis here and am referring any further issues to my premium support forum.

Tory H
05-19-2006, 04:18 PM
Hi Amy,
I need this mod to read a different field (referrer) rather than profile field.

Basically the user is put into a usergroup based on what field is filled out as referrer (automatically passed from URL). Basically if they are my referral they are top dog permissions because they are somebody who I can trust, if a troll refers them then maybe they get put into a special group.

Will this work do you think?
Thx
Matt

futuredood
06-16-2006, 03:10 AM
Hey. :) Well It was working for the secondary user-group. Although I found out that I needed one for the primary group. So Amykhar helped me out with this slight modification of the script... Works on my board (3.5.4).

switch($userinfo['field5'])
{
case "A":
$userdata->set('usergroupid', 12);
break;
case "B":
$userdata->set('usergroupid', 13);
break;
case "C":
$userdata->set('usergroupid', 18);
break;
}

Talk to you later,
Paul F

I presume this means you can let the user input the actual text in the case "X" area, correct? In that case, can you tell me where I would place this in the XML file?

I plan on having available more usergroups in the future, and would like to have the individual be able to type in the group they are entering (I'd have a link to the possibilities on the registration page).

Also, has their been any changes so that this could work all the time (for example, they can change their usergroup as they like through edit profile)? Thanks.

ThePiston
06-19-2006, 08:02 PM
can someone post some working, multi-item xml code? I got mine working for multiple raio buttons with the secondary code, but i switched all of those groups to 'non-joinable custom/primary' usergroups and now I get nothing showing up when Iclick the registration email link and I can't get it to work. I've trid every combination i can think of... Ive got the right field, correct spelling and syntax, groups... i think i need to see someone's successful code for a multi-item xml file to compare. tia

this is the code i have now that does not want to work:
// Get the value for field 5
$user = $db->query_first("
SELECT field5
FROM " . TABLE_PREFIX . "userfield
WHERE userid = " . $vbulletin->userinfo['userid'] . "
");


if ($user['field5'] == 'Yes')
{
$userdata->set('usergroupid', 15);
}

else if ($user['field5'] == 'No')
{
$userdata->set('usergroupid', 17);
}

else if ($user['field5'] == 'Always')
{
$userdata->set('usergroupid', 19);
}

else if ($user['field5'] == 'Never')
{
$userdata->set('usergroupid', 20);
}


I tried using all 'if's but that didn't work either... i'm not too hip on PHP, but i should be able to crack this?!

JazzleBug
06-30-2006, 05:18 PM
This installed beautifully, Amy! I'm all about automation and this cuts down on quite a bit of work for me. Thank you!

amykhar
06-30-2006, 05:51 PM
happy to be of service :)

ToastBusters
07-07-2006, 04:51 PM
Hey,

I would like to have a the usergroup be based on the email domain. i.e. if the register with one domain they get put in a special usergroup but if it's any other domain they are simply put into registered users. Is this possible with this plugin?

Thanks!

paulfletcher
07-07-2006, 05:12 PM
Hello. You can definitely set it up so if a user is from a certain domain they get put into a special user-group. You just setup a text field, and point this script towards this text field, and your good to go. You could probably setup the script to do an "if and or" statement. If it's from this domain do this, otherwise do this. But I'm not the person to ask about how to program this... But it can be done.

Thanks,
Paul

ToastBusters
07-07-2006, 05:16 PM
Do you know off the top of your head what the variable is that holds the users email address? I could just get the domain off of that.

paulfletcher
07-07-2006, 05:19 PM
I don't know off the top of my head what this variable is. You could try contacting vBulletin.com support.

Thanks,
Paul

cddw.ltd
07-11-2006, 09:58 AM
Anyone got any links to a similar system that would allow users to either switch their primary usergroup or secondary at any time via the control panel?

Aurons Ghost
07-27-2006, 10:09 AM
Thank you for this mod. It was just what I was looking for :)

on a side note though, if you don't have email confirmation, do you know which hook to use?

Neo_obs
08-02-2006, 05:24 AM
I have a question is there anyway to mass add the users that have already registered to that usergroup?

if i ran this as a cron would it do it?

// Get the value for field 11
$user = $db->query_first("
SELECT field11
FROM " . TABLE_PREFIX . "userfield
WHERE userid = " . $vbulletin->userinfo['userid'] . "
");

if ($user['field11'] == 'No')
{
$userdata->set('usergroupid', 18);
}

or if i add it as a hook somewhere else on the site? like forumhome?

Neo_obs
08-10-2006, 05:08 AM
Can anyone tell me what other hooks I can use this doesnt work on our forums if they activate manually.

rb290
08-21-2006, 11:23 PM
Can anyone tell me what other hooks I can use this doesnt work on our forums if they activate manually.

same deal ^

i dont use email verification so is there any other solution to make this hack work cause i need it...

cavyspirit
08-26-2006, 02:50 PM
How is this for 3.6? I absolutely need this one.

kall
09-15-2006, 09:26 PM
Working fine for me on 3.6.0 and 3.6.1 :)

ricker
09-21-2006, 10:53 PM
I thought it wasn't working, but then through troubleshooting I realized that the value of my field couldn't have both numbers and letters. I switched it to just letters and my test account was properly switched into the new usergroup.

If I want to set up multiple "custom registration codes," can I duplicate this script and rename it, changing the values?

kderentz
09-29-2006, 06:18 PM
Working fine for me on 3.6.0 and 3.6.1 :)

Glad to hear this works on 3.6.1 as that what I plan on using it on.


Amy this hack is exactly what I have been looking for except I have a couple of questions.

I've set up a custom user profile field that asks the user upon registration if they are a reatil buyer or wholesaler and I'm using a radio button to ask them.

Now with your code if they select on item it puts them in a certain user group, but what if they pic the other? do they just go in the default user group?

I want it to place them in eaither group depending on what they pic. I hope this makes sense.

amykhar
09-29-2006, 06:30 PM
This mod is more of a template for you to decide what you want to do with users based on that profle field. You code the logic of where they are sorted. The mod itself hooks to the right place and gets you started so you can see how to inspect the value of the field and how to put the user in a group.

kderentz
09-29-2006, 06:39 PM
This mod is more of a template for you to decide what you want to do with users based on that profle field. You code the logic of where they are sorted. The mod itself hooks to the right place and gets you started so you can see how to inspect the value of the field and how to put the user in a group.

Thats where im limited as my code knowledge is lacking :confused:

Could you help me out with this ...

say my user field is 5 and my options are Dealer or End User

my user group for Dealers is 10 and my user group for End Users is 11

would my code look something like this???:

if ($user['field5'] == 'Dealer')
{
$userdata->set('usergroupid', 10);

if ($user['field5'] == 'End User')
{
$userdata->set('usergroupid', 11);

RFViet
10-10-2006, 07:53 PM
Installed, it would be helpful to my forum :D

vietkieu_cz
10-19-2006, 02:32 PM
I need this plugin for my forum. :)

kall
10-19-2006, 06:09 PM
I need this plugin for my forum. :)
Given that there's no vB verson 5.0.55, perhaps I could suggest you tell us what version you are running.

(It works on 3.5.x and 3.6.x).

vietkieu_cz
10-19-2006, 06:35 PM
Given that there's no vB verson 5.0.55, perhaps I could suggest you tell us what version you are running.

(It works on 3.5.x and 3.6.x).
I'm using vBb version 3.6.2 not 5.0.55 (I'm just joking):P
I think that all vBb customers use the newest vBb version.

Oreamnos
10-29-2006, 03:11 AM
Can anyone tell me what other hooks I can use this doesnt work on our forums if they activate manually.same deal ^

i dont use email verification so is there any other solution to make this hack work cause i need it...
I'd also be interested in knowing which hook to use if the account does not require email verification. :)

Oreamnos
10-30-2006, 02:42 AM
NOTE: This mod works for forums that require users to verify their email address upon registration. If your forum does not require users to verify their email address, you will need to use a different hook. If I have time, I'll test that variation.
OK, after I registered about 20 new test users here is what i found regarding this plugin's use with non-email verification registrations.

I tried almost every register_hook_name and none of them worked. it doesn't seem like it's possible to process this plugin without using the email verification function.

That being said, if you only want to move a user to another primary group on registration without a custom field being checked, you can still do this:

Add this:$userdata->set('usergroupid', 11);
(where 11 is the ID of the new primary usergroup)

Hook that with:
register_addmember_process

Activate and every member that registers on your site will have their primary group changed to ID: 11 (or whatever your choose)

i hope this info helps and saves some people a lot of time.

eric

DeMagH
11-27-2006, 04:17 PM
it should be hooked correctly in my forums "using 3.6.2" but it doesn't seem to work
here is my code, please let me know if something is wrong: "i use field5 by the way"

if ($user['field5'] == 'Egypt')
{
$userdata->set('usergroupid', 14);
}
if ($user['field5'] == 'Canada')
{
$userdata->set('usergroupid', 18);
}
if ($user['field5'] == 'Saudi Arabia')
{
$userdata->set('usergroupid', 15);
}
if ($user['field5'] == 'United Arab Emirates')
{
$userdata->set('usergroupid', 16);
}
if ($user['field5'] == 'United Kingdom')
{
$userdata->set('usergroupid', 17);
}
if ($user['field5'] == 'United States')
{
$userdata->set('usergroupid', 10);
}
if ($user['field5'] == 'Other')
{
$userdata->set('usergroupid', 19);
}

checked usergroupid matching
checked field matching
checked case sensitivity
is there anything else to check?!

note:
my field type is single selection menu, should i change it into radio buttons?

note:
here how the code is appearing in the plugins manager section:

// Get the value for field 5
$user = $db->query_first("
SELECT field5
FROM " . TABLE_PREFIX . "userfield
WHERE userid = " . $vbulletin->userinfo['userid'] . "
");


if ($user['field5'] == 'Egypt')
{
$userdata->set('usergroupid', 14);
}
if ($user['field5'] == 'Canada')
{
$userdata->set('usergroupid', 18);
}
if ($user['field5'] == 'Saudi Arabia')
{
$userdata->set('usergroupid', 15);
}
if ($user['field5'] == 'United Arab Emirates')
{
$userdata->set('usergroupid', 16);
}
if ($user['field5'] == 'United Kingdom')
{
$userdata->set('usergroupid', 17);
}
if ($user['field5'] == 'United States')
{
$userdata->set('usergroupid', 10);
}
if ($user['field5'] == 'Other')
{
$userdata->set('usergroupid', 19);
}

DeMagH
11-29-2006, 11:47 AM
bumping thread

amnesia623
11-30-2006, 02:32 PM
does this work in 3.6.4?

amykhar
11-30-2006, 06:43 PM
Yes. It's still running unchanged on my site.

wes_517
11-30-2006, 11:00 PM
This is VERY close to exactly what my members are asking for, but I would need one small change...

Most of my site is closed off to non-members, and so to make sure who I am adding, I have to moderate all new users for privacy reasons...

So instead of adding new users directly to the group, what would I need to change to add them into the moderation queue instead?

I'm decent with PHP and Mysql, but still learning ins and outs of vbulletin...

any help?
--edit 1--
Thinking about this more, is that POSSIBLE for a primary group? (if the user logs in while their primary group is still under review, wouldn't they then not belong to ANY group and be denied access?)

--edit 2--

I hacked some code out, it may not be pretty, but it's working...

https://vborg.vbsupport.ru/showthread.php?p=1129131#post1129131

since it modifies the secondary user, i posted it over there... anyone have an idea on the edit 1 question? can that be done or would it throw a fit because they wouldn't have a group yet?

salata
12-08-2006, 01:36 PM
i am having diffulculty getting this to work for me, i am using 3.5.4

<?xml version="1.0" encoding="ISO-8859-1"?>

<plugins>
<plugin active="1" product="vbulletin">
<title>Put User In User Group Based on Field Value</title>

<hookname>register_activate_process</hookname>
<phpcode><![CDATA[// Get the value for field 25
$user = $db->query_first("
SELECT field25
FROM " . TABLE_PREFIX . "userfield
WHERE userid = " . $vbulletin->userinfo['userid'] . "
");


if ($user['field25'] == 'No')
{
$userdata->set('usergroupid', 36);
}]]></phpcode>
</plugin>
</plugins>

yingzhou
12-21-2006, 06:19 AM
can this mod work on vb 3.6.x? Im using 3.6.4 now.

DeMagH
12-25-2006, 05:37 PM
can this mod work on vb 3.6.x? Im using 3.6.4 now.

yeah worked for me in 3.6.2

Mum
01-12-2007, 07:18 PM
I installed this, but when i registered a new user to test it, it hasn't added it to the group at all. This is my very first plug in, so may be something i've done wrong. PLease help :)

// Get the value for field 5
$user = $db->query_first("
SELECT field5
FROM " . TABLE_PREFIX . "userfield
WHERE userid = " . $vbulletin->userinfo['userid'] . "
");


if ($user['field5'] == 'Female')
{
$userdata->set('usergroupid', 11);

if ($user['field5'] == 'Male')
{
$userdata->set('usergroupid', 13);
}

DeMagH
01-16-2007, 01:47 AM
after 2 months of using this with vbulletin v3.6.2 here is what is happening:
- most of the time it is working fine "80% of the time"
- sometimes instead of getting the user to the right group it gets him to REGISTERED "15%"
- sometimes the user fails to get the activation email "not sure if this is caused by this plug in or not, but this is the ONLY plug in hooked with user_activate_process" "5%"

This sample is taken from different 150 different registrations randomly from hotmail/gmail/yahoo/others users.

will disable it within 24 hours and wait for another month to see what will happen and if there will be any change in percentages given above.

salata
02-02-2007, 02:38 AM
i am having diffulculty getting this to work for me, i am using 3.5.4

<?xml version="1.0" encoding="ISO-8859-1"?>

<plugins>
<plugin active="1" product="vbulletin">
<title>Put User In User Group Based on Field Value</title>

<hookname>register_activate_process</hookname>
<phpcode><![CDATA[// Get the value for field 25
$user = $db->query_first("
SELECT field25
FROM " . TABLE_PREFIX . "userfield
WHERE userid = " . $vbulletin->userinfo['userid'] . "
");


if ($user['field25'] == 'No')
{
$userdata->set('usergroupid', 36);
}]]></phpcode>
</plugin>
</plugins>




Bump!!

wtrk
02-07-2007, 05:58 PM
is there a way to do this to users after they have registered?

how can i force users who have already answered the question into the usergroup?

kall
02-19-2007, 02:51 AM
Hey amy.. should this plugin work with NON custom profile fields? ie: default ones?

I have noticed a pattern with certain spambots, they always use 'Man' as field1.

Altering the plugin code to the following doesn't seem to work.

// Get the value for field 1
$user = $db->query_first("
SELECT field1
FROM " . TABLE_PREFIX . "userfield
WHERE userid = " . $vbulletin->userinfo['userid'] . "
");


if ($user['field1'] == 'Man')
{
$userdata->set('usergroupid', 8);
}

Any ideas?

Benj
03-30-2007, 06:25 PM
any ideas if this works with the latest version ?

kall
03-30-2007, 06:32 PM
Kinda.

Well, 90% of the time for me. :)

vuiveclub
04-18-2007, 08:22 PM
Does this mod work in <hookname>register_activate_process</hookname> only?
I don't wanna use email for registration.

Medina
05-20-2007, 05:49 PM
*notification*

Murty
05-29-2007, 10:50 PM
Hey guys,

For those of you interested, a guy has created a modification that will move users to a specified usergroup depending on a profile field selection.
For me, when a user registers, they need to select whether they are male or female. Once they have registered, depending on whether they selected male or female, they get moved to the male or female user group i created.

You are able to get this mod by sending an email to: hugh@alaweb.com and requesting the 'user profile group modification'.
This mod was not made for free, so it will cost you $25.00 US.

I have tested it with vb 3.6.5 and it works great, highly recommend!

PM me if you want more info.

Medina
06-18-2007, 08:23 AM
Hey. :) Well It was working for the secondary user-group. Although I found out that I needed one for the primary group. So Amykhar helped me out with this slight modification of the script... Works on my board (3.5.4).

switch($userinfo['field5'])
{
case "A":
$userdata->set('usergroupid', 12);
break;
case "B":
$userdata->set('usergroupid', 13);
break;
case "C":
$userdata->set('usergroupid', 18);
break;
}

Talk to you later,
Paul F


Hello,

I have made it like this;

switch($userinfo['field5'])
{
case "Male":
$userdata->set('usergroupid', 30);
break;
case "Female":
$userdata->set('usergroupid', 29);
break;
}

and added beneath the the plugin


// Get the value for field 5
$user = $db->query_first("
SELECT field5
FROM " . TABLE_PREFIX . "userfield
WHERE userid = " . $vbulletin->userinfo['userid'] . "
");

if ($user['field5'] == 'Male')
{
$userdata->set('usergroupid', 30);
if ($user['field5'] == 'Female')
{
$userdata->set('usergroupid', 29);
}
switch($userinfo['field5'])
{
case "Male":
$userdata->set('usergroupid', 30);
break;
case "Female":
$userdata->set('usergroupid', 29);
break;
}

Am I doing this right?

Thanks for a reply, of any advanced person with this script ;)

Medina
06-21-2007, 01:19 PM
please, could somebody help me :(

any moderators/coders?

kjhkjh
10-03-2007, 07:29 PM
I have imported this into 3.6.8 after the making the changes but my test users aren't being put into the correct groups based on their registration field selection.

Can anyone help?

This is a fresh install of vb and I have done the necessary changes as outlined in the instructions here? :(

If I can get it working it would save me a lot of work,

Thanks

vuiveclub
10-21-2007, 06:18 PM
Can someone write cron something like this?
I mean automatic move to an usergroup if that user is Female? :)
Thanks

bschneider5
10-26-2007, 10:57 AM
How can I do this with this mod.....

Spammers 99% of the time put a url in my FULL NAME field, and I would like to use this mod if possible. I installed it, and want any user that enters "http" in the FULL NAME field to be moved to the banned usergroup. This is the code I'm using but it doesn't work:
// Get the value for field 6
$user = $db->query_first("
SELECT field6
FROM " . TABLE_PREFIX . "userfield
WHERE userid = " . $vbulletin->userinfo['userid'] . "
");


if ($user['field6'] == 'http')
{
$userdata->set('usergroupid', 8);
}

SVTCobraLTD
01-27-2008, 03:03 PM
Is this still be supported? I tried installing on the board with no luck. 3.6.8pl2. Anyone?

vbob
02-02-2008, 10:29 PM
Hi, It seems that you've got a very interesting mod here. :-)
I have Vbulletin 3.6.8 Patch Level 2
and vBadvanced CMPS v3.0 RC2 installed to my forum. Will it work to my forum or it works only with 3.5.x??? Should I try it?? Can you provide us with a 3.6.8 version that works for sure? (I haven't try it yet...because I am waiting for your answer first). :-)

Demo16
02-11-2008, 05:42 PM
Can I use this mod to do this: all users that have EN language are automatically moved to usergroup: en_users

can I do this? I have also Vbulletin 3.6.8 Patch Level 2

Demo16
02-16-2008, 08:15 AM
it doesn't work for me, any help?

wtrk
03-26-2008, 09:01 PM
is there a way to move people who have already answered the question?

WNM07
05-15-2008, 01:41 PM
i would like to incorporate this into my postbit using this as a base so that the admin can change the users primary usergroup from the postbit .. can't figure out how any idea?

<if condition="$bbuserinfo[usergroupid] == 6">
<tr><td class="vbmenu_option"><span onmouseover="this.style.cursor='hand';" onClick="window.open('modcp/banning.php?do=banuser&userid=$post[userid]','ban','width=500,height=375,scrollbars=yes')"><b>Ban User: $post[username]</b></span></td></tr><tr><td class="vbmenu_option"><a href="moderator.php?do=useroptions&u=$post[userid]">Edit User: $post[username]</a></td></if>

Conner85
05-24-2008, 09:04 AM
Someone needs to update this for 3.7 Gold. It's causing registration errors for my users.

oz_girl
05-27-2008, 01:55 AM
This is perfect for my forums but is this 3.7 Gold compatible?

oz_girl
05-28-2008, 09:02 AM
Anyone using this successfully on 3.7 gold or 3.7.1??

jpapadpapa
06-07-2008, 12:40 AM
I, too, really need this for 3.7.1!

steven s
09-04-2008, 05:42 PM
Anyone using this successfully on 3.7 gold or 3.7.1??

I, too, really need this for 3.7.1!
Just installed it on v3.7.3.

THANKS!
This is the answer I've been looking for.
It will automatically ban my spammers.

Edit: Also works on 3.7.4 p1

steven s
11-02-2008, 11:29 AM
This is an old one but I love it.
Spammers usually enter the same number into my location profile field.
Bam, automatic ban. Just banned two more.
They have gotten past answering questions which I'm sure stops a few, and this mod is just another measure.

YESS
12-23-2008, 07:40 PM
Thank you Amy this is exactly what my client needed to perfect their forums.

Now all I need to do is learn how to do something like this with a cron job so that users who are already registered can choose something in their profile to 'upgrade' their account and set their primary usergroup.

YESS
12-23-2008, 11:22 PM
There we go, I went ahead and wrote a Scheduled Task that every 10 minutes would check for anybody in the primary group 'Registered users' with the custom profile field9 set to 'Yes' and move them to usergroup 9, and vice versa. Sorry in advance for unclean code and please don't hate.

Place the code in the box below in a .php script in your /includes/cron folder and create a new scheduled task pointing to that script.

Replace 'field9' with the field you want to check. Replace 'Yes' and 'No' with the values of your field9 option.

Replace 'New member' and 'Introductory grower/distributor' with your chosen user titles.

Replace the usergroup numbers 2(Registered member) and 9(Custom usergroup) on the MySQL queries with the numbers of the usergroups you want to migrate to and from.

Sorry I can't go into more detail, sort of in a hurry to get this job done for my client. I don't recommend attempting this if you are not comfortable editing SQL queries.

Be sure to test this out on your forums using the 'Run now' option from the Scheduled Tasks section of the control panel, if you have messed up the syntax at all the control panel should return an error and send a copy of the error to the board owner via email.

I recommend backing up your databases before trying this out just in case you do something wrong, I don't hold any responsibility for lost or corrupt data in your database.

P.S. I recommend putting a notice in your custom usergroup description letting the user know that it can take up to 10 minutes for the changes to take effect to avoid confusion. (Or whatever interval you set your scheduled task job to.)

<?php
error_reporting(E_ALL & ~E_NOTICE);
if (!is_object($vbulletin->db))
{
exit;
}

$tmpA = $vbulletin->db->query_read("
SELECT user.userid,user.usergroupid,user.username
FROM `user`,`userfield` AS field
WHERE user.usergroupid = 2
AND user.userid=field.userid
AND field.field9='Yes'
");

while ($tmpU = $vbulletin->db->fetch_array($tmpA))
{
$vbulletin->db->query_write("
UPDATE " . TABLE_PREFIX . "user
SET usergroupid = 9, usertitle='Introductory grower/distributer'
WHERE userid = " . $tmpU['userid']);
}




$tmpA = $vbulletin->db->query_read("
SELECT user.userid,user.usergroupid,user.username
FROM `user`,`userfield` AS field
WHERE user.usergroupid = 9
AND user.userid=field.userid
AND field.field9='No'
");

while ($tmpU = $vbulletin->db->fetch_array($tmpA))
{
$vbulletin->db->query_write("
UPDATE " . TABLE_PREFIX . "user
SET usergroupid = 2, usertitle='New member'
WHERE userid = " . $tmpU['userid']);
}
?>

forexforum
01-21-2009, 02:44 PM
Hi there,

Does it work on the latest vB 3.8? I need this. Thank you all. :confused:

amjadz4
03-29-2009, 05:09 PM
i need this for the latest vb too!! can you please update it!!
thanks!

steven s
06-20-2009, 09:55 PM
Hi there,

Does it work on the latest vB 3.8? I need this. Thank you all. :confused:

i need this for the latest vb too!! can you please update it!!
thanks!
It works fine in 3.8.3.

CAAC
11-18-2009, 09:59 PM
Amy, this plugin works great and was exactly what I needed.

Would you know if there is any quick way to also update the User Title at the same time. I am moving people to a usergroup with a custom title but they all show up in the correct usergroup but with the title from the default registered users group.

Thanks!

SVTCobraLTD
12-21-2011, 07:23 PM
I have been getting hit with a lot of spam. They always put a certain work in the bio so this will help me send them right to banned.

Just tried this on 3.8.x and it did not work. Still went right to the regular group.

Manoel J?nior
01-30-2012, 11:30 PM
Please, update for 4.x

Tyran1
04-02-2012, 10:43 PM
I Need a fix for 3.8.7 please!!!

temsamane
04-03-2012, 08:08 PM
i need this mod for vb 4 please!

Tyran1
04-08-2012, 02:07 AM
I need a fix for 3.8.7 please!!!!!

olalaaa
04-11-2012, 01:44 PM
4.1.11 please

meadwench
05-07-2013, 02:06 PM
Plus 1 to have it for 4.x. This would be just the ticket for my site....

dany_danay
12-22-2013, 04:06 PM
PLEASE for 4!!