The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
AUTOJOIN - Auto-entry in membergroup via field in profile Details »» | |||||||||||||||||||||||||||
AUTOJOIN - Auto-entry in membergroup via field in profile
Developer Last Online: Oct 2016
Here's a little something to give back to this community that has been of such help to me.
With this plugin, you can have a user entered into or removed from a secondary usergroup according to several types of controls that can be placed in the user's profile via custom fields. This acts only on SECONDARY usergroups and will not affect the user's PRIMARY usergroup. At each login, the plugin will check for the appropriate setting in the user's profile, then add or remove the user from the specified membergroup as appropriate. Note that this does not act instantaneously upon entry of the data in the profile, but requires a new login for this to take effect. [Starting with vB 3.6.4 (maybe earlier, I didn't install anything between 3.5.4 and 3.6.4) this will take effect with one or two page reloads.] Controls currently available: 1) Password for single usergroupNote that you may write your own additional controls and use the two included functions to do the actual insertion into, and removal from, the target usergroups. Tested with vB 3.5.4, 3.6.4, 3.6.7-PL1, 3.8.7PL3 only. Full instructions are in the downloadable text file autojoin.txt. Update log:
Show Your Support
|
Comments |
#52
|
||||
|
||||
See also this somewhat similar add-on:
https://vborg.vbsupport.ru/showthread.php?t=82993 Had I known of its existence I probably wouldn't have created this one. |
#53
|
|||
|
|||
makaiguy, Your hack worked perfect for me, we are using your code with a single choice menu to pick a home state, we run a jeep wrangler forum, and are using your hack to allow us to do local and regional forums based upon this choice.. regardless of another hack being out there. Thanks a Ton, Don
|
#54
|
||||
|
||||
Just updated my test board to vB 3.6.7-PL1. Original code from 3.5.4 continues to work as desired.
If you've installed this plugin, please don't forget to click the Installed link in the first post. |
#55
|
|||
|
|||
Please help me urgently, i added your details in and now i can't access my forum AT ALL. How can i turn it off? I can't access my admin panel or anything. Please help.
I went to vB AdminCP, go to Plugin System > Add New Plugin. Under Hook Location, scroll down to select 'global_start'. In the 'Plugin PHP Code' field, copy/paste your edited control script from Part I. // Place user in/out of single usergroup // according to yes/no selection made in profile, via // custom radio button field. ver 1.04 // Enter values in the strings below for your forum // custom field containing your radio button $radio_field = 'field10'; // Text returned for 'yes' choice $join = 'Female'; // Usergroup to enter/exit $ug = '33'; // You don't need to enter anything below here. // Derive additional needed variables // userid of user $userid = ($vbulletin->userinfo['userid']); // current usergroups as array $ugarr = explode(',' , (''.$vbulletin->userinfo['membergroupids'])); // current radio button setting $fieldval = $vbulletin->userinfo[$radio_field]; // Do the work // Proceed only if there is a user choice if ($fieldval != '') { // If yes, add to usergroups if ($fieldval == $join) { $ugarr = IntoGroup($ugarr, $ug, $userid); } // Else no, remove from usergroups else { $ugarr = OutOfGroup($ugarr, $ug, $userid); } } // End of Control Code // Define functions used in plug-in // ***************** Function IntoGroup() ************** Function IntoGroup($ugarr, $ugnum, $usrid) { global $vbulletin; // only proceed if not trying to put into current primary usergroup if ($ugnum != $vbulletin->userinfo['usergroupid']) { // check for empty usergroup array if($ugarr[0] == '') { // set veriables $uglist = $ugnum; $ugarr[0] = $ugnum; $doit = true; } // usergroup array not empty else { // If not in usergroup already if(!in_array($ugnum, $ugarr)) { $doit = true; // add group to end of array array_push($ugarr, $ugnum); // sort numerically sort($ugarr, SORT_NUMERIC); // if only one group in array if (count($ugarr) == 1) { // simple group list string with no commas $uglist = $ugnum; } // else more groups in array than one else { // group list string with comma delimiters $uglist = implode(',' , $ugarr); // convert array to string } } } if ($doit) { // Put updated usergroup list into database $updatefields = $vbulletin->db->query(" UPDATE user SET membergroupids='$uglist' WHERE userid=$usrid "); } } return $ugarr; } // ***************** Function OutOfGroup() ************** Function OutOfGroup($ugarr, $ugnum, $usrid) { global $vbulletin; // only proceed if not trying to remove from current primary usergroup if ($ugnum != $vbulletin->userinfo['usergroupid']) { // Proceed only if usergroup array not empty if($ugarr[0] != '') { // Check for target usergroup in existing array if(in_array($ugnum, $ugarr)) { // Rebuild array without target usergroup $iii = 0; foreach ($ugarr as $value) { if ($value != $ugnum) { $new_gparr[$iii] = $value; $iii++; } } $ugarr = $new_gparr; if (count($ugarr) == 0) { $uglist = ''; } else { $uglist = implode(',' , $new_gparr); } // Put updated usergroup list into database $updatefields = $vbulletin->db->query(" UPDATE user SET membergroupids='$uglist' WHERE userid=$usrid "); } } } return $ugarr; } // End of function code |
#56
|
||||
|
||||
Quote:
See this post for information on how to completely disable the hook system so that no plugins will run. If your ONLY problem is with a plugin installation, this should allow you to access your AdminCP: http://www.vbulletin.com/forum/showthread.php?t=196688 |
#57
|
|||
|
|||
This mod is excellent and works a charm. I've added it to my clan website.
I've set it to appear in the "edit profile" as 2 radio buttons however.... what I would really like is a custom page showing two images/buttons. When clicking on one it will add you to that usergroup. Is that possible? THANKS D |
#58
|
||||
|
||||
Quote:
Here's a tutorial on creating vB-based php pages: https://vborg.vbsupport.ru/showthread.php?t=62164 |
#59
|
||||
|
||||
We're in the middle of finally updating vB from 3.6.4 to 3.8.7-PL3 (long, long overdue). Although I'm having some difficulty getting some of my other tweaks to work, I'm pleased to announce that this mod continues to perform as written.
|
Thread Tools | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|