The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Add User to Secondary Usergroup Based on the Value of a Custom Profile Field at Reg. Details »» | |||||||||||||||||||||||||||
Add User to Secondary Usergroup Based on the Value of a Custom Profile Field at Reg.
Developer Last Online: Nov 2013
This version is for the SECONDARY group. The one for primary groups is here:
https://vborg.vbsupport.ru/showthread.php?t=82992 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 secondary user group based on that selection. 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"?> <plugins> <plugin active="1" product="vbulletin"> <title>Put User in Secondary Group Based on Custom Profile 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') { $membergroupids = $userdata->fetch_field('membergroupids'); if ($membergroupids) { $membergroupids = $membergroupids . ", 10"; } else { $membergroupids = 10; } $userdata->set('membergroupids', $membergroupids); }]]></phpcode> </plugin> </plugins> Example: if you are checking your field to see if the value is male, you would change (change field number as needed): Code:
if ($user['field5'] == 'yes') Code:
if ($user['field5'] == 'male') Code:
$membergroupids = $membergroupids . ", 10"; And in this line as well, Code:
$membergroupids = 10; 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. ---------------- Example Gender Mod that separates users into secondary groups based on their gender. Don't forget, the values are case sensitive and the field numbers and usergroup numbers need to be changed to suit your site's setup. Code:
// Get the value for field 20 $gender = $vbulletin->db->query_first("SELECT * FROM userfield WHERE userid=".$vbulletin->userinfo['userid']); if ($gender['field20'] == 'male') { $membergroupids = $userdata->fetch_field('membergroupids'); if ($membergroupids) { $membergroupids = $membergroupids . ", 42"; } else { $membergroupids = 42; } $userdata->set('membergroupids', $membergroupids); } else { $membergroupids = $userdata->fetch_field('membergroupids'); if ($membergroupids) { $membergroupids = $membergroupids . ", 41"; } else { $membergroupids = 41; } $userdata->set('membergroupids',$membergroupids); } Show Your Support
|
Благодарность от: | ||
Insta-Gator |
Comments |
#42
|
|||
|
|||
Does this still work if I'm using CMPS on my board? Do I have to change the "Product" option in vbulletin from "vBulletin" to "CMPS" when I'm installing this?
|
#43
|
|||
|
|||
Anyone :-)...? So alone...
|
#44
|
||||
|
||||
Why wouldn't it and why would you?
|
#45
|
|||
|
|||
lol. I don't know. I'm new to vBulletin, and so far. When I've tried installing this script it still doesn't work. I've made sure my text field during registration is not hidden, and that it is field5, and that its upgrading to the correct usergroup ID. (just like your script). And I've tried typing in the correct information so my account can be upgraded, although... Still no luck. The newly registered user is still not being upgraded.
So I was thinking that it was probably my stupidity that was preventing the script from being correctly installed. Any thoughts? Thanks, Paul Fletcher |
#46
|
|||
|
|||
Would you, are someone be willing to help me install this plugin and get it working. I'll get you an admin login for our forum.
Thanks, Paul |
#47
|
|||
|
|||
Alright. So, our site has to open on March 27th, and I'm clueless on how to make this script work. After installing the script... Everything the same (except groupID has been changed from 10 to 11.
I get this error when I activate my account. Parse error: parse error, unexpected '<' in /homepages/9/d89699556/htdocs/xyztraining_com/register.php(930) : eval()'d code on line 1 When looking in the registration.php file on line 930 I see this... $hook = vBulletinHook::fetch_hook('register_activate_proce ss')) ? eval($hook) : false; Does this help anyone figure out where my problem may be lying? Thanks, Paul |
#48
|
|||
|
|||
Quote:
|
#49
|
|||
|
|||
Thats what I originally though as well, but Amykhar told me that she has it working on vBulletin 3.5.4.
Wouldn't this error Quote:
Any thoughts? Thanks, Paul |
#50
|
||||
|
||||
paul, my software for work just went out the door and I have about half an hour of free time before I need to get back to work. PM me your admin info and I'll see what I can do for you.
|
#51
|
|||
|
|||
I sent the login credentials to you.
Thanks again, Paul |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|