![]() |
Add User to Primary Usergroup Based on Value of Custom Profile Field
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. Code:
<?xml version="1.0" encoding="ISO-8859-1"?> Code:
if ($user['field5'] == 'yes') Code:
if ($user['field5'] == 'male') Code:
$userdata->set('usergroupid', 10); 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 |
Hello, I cannot seem to find the alternate "female" option in your code examples.
How does one go about adding that? |
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: Quote:
Please help :( |
please help. :(
|
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 |
Quote:
Anything else I could have missed? |
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.
|
Quote:
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? |
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. |
Quote:
it's a beta 4. but, i don't want the words "beta" anywhere on my site, so I pwnd it. |
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. :) |
Quote:
I'm buying the full version next week, so... anyone have sucess with this on Beta 4? |
Quote:
|
Quote:
|
Quote:
|
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.
|
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 |
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
|
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 |
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?
Code:
<?xml version="1.0" encoding="ISO-8859-1"?> |
Quote:
|
Not going to get a response from that user. She was banned.
|
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 :) |
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.
|
Great! Thanks, and I will still have use for your hack. :)
|
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!
|
I know that Brinnie is banned, but if anyone else is having a problem like her's, make sure that
Code:
if ($user['field5'] == 'yes') I think Amy said that somewhere in here too. |
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 |
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 |
Quote:
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 |
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 |
Quote:
Marry Me? Rabbit (with respect) |
Doh. Sorry for my stupid initial response. Let me look at it a bit and get back to you. I'm multitasking right now.
|
Quote:
Quote:
Thx Will Check Back LATER!! Rabbit |
Quote:
|
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); } |
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: Code:
<?xml version="1.0" encoding="ISO-8859-1" ?> When I click the activation link in the email, a blank window pops up with this address... http://www.mydomain.com/forums/regis...=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. |
fixed
|
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 |
Can anyone help me? :)
|
All times are GMT. The time now is 04:43 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|