Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.5 > vBulletin 3.5 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
AUTOJOIN - Auto-entry in membergroup via field in profile Details »»
AUTOJOIN - Auto-entry in membergroup via field in profile
Version: 1.05, by makaiguy makaiguy is offline
Developer Last Online: Oct 2016 Show Printable Version Email this Page

Version: 3.5.4 Rating:
Released: 03-31-2006 Last Update: 06-05-2006 Installs: 18
Uses Plugins
Re-useable Code Translations  
No support by the author.

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 usergroup
2) Yes/No choice for single usergroup via radio button
3) Choose one of several usergroups via radio buttons
4) Choose any of several usergroups via multiple checkboxes
Note 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:
  • 1.00 - Initial release
  • 1.01 - Sorts output membergroups numerically plus a few other small changes
  • 1.02 - Rewritten using defined functions for adding to, and removing from, memberbgroups. This should make it easier to follow the logic and to adapt the code for other situations (e.g.checkboxes or radio buttons instead of text profile fields)
  • 1.03 - InGroup() and OutGroup() functions rewritten to make them more useful when dealing with other situations than the somewhat restricted application of entry/exit of specific membergroup via stored password.
  • 1.03.1 - Additional tweaking of InGroup() and OutGroup() functions. Tested extensively and seem to be working as intended. Tested examples of using via radio buttons instead of text field added.
  • 1.04 - Added protection against doing anything re user's current PRIMARY usergroup in secondary usergroup list. Functions renamed to IntoGroup() and OutOfGroup().
  • 19 April 2006 - all code moved from this thread into the downloadable text file.
  • 1.05 - Added control for using multiple checkboxes to choose any of several usergroups.
  • 22 May 2007 - tested with vB 3.6.7-PL1
  • 24 Sep 2012 - tested with vB 3.8.7-PL3

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #52  
Old 12-08-2006, 04:08 PM
makaiguy's Avatar
makaiguy makaiguy is offline
 
Join Date: May 2004
Location: Aiken, SC, USA
Posts: 150
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #53  
Old 12-08-2006, 05:54 PM
everd everd is offline
 
Join Date: Nov 2006
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #54  
Old 05-23-2007, 12:08 AM
makaiguy's Avatar
makaiguy makaiguy is offline
 
Join Date: May 2004
Location: Aiken, SC, USA
Posts: 150
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #55  
Old 05-29-2007, 07:21 AM
Mum Mum is offline
 
Join Date: Jun 2006
Location: New Zealand
Posts: 660
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #56  
Old 05-29-2007, 10:36 PM
makaiguy's Avatar
makaiguy makaiguy is offline
 
Join Date: May 2004
Location: Aiken, SC, USA
Posts: 150
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Mum View Post
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.
Mum - nobody else has reported anything like this.

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
Reply With Quote
  #57  
Old 06-07-2007, 03:34 PM
dooch dooch is offline
 
Join Date: Dec 2005
Posts: 126
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #58  
Old 06-07-2007, 08:21 PM
makaiguy's Avatar
makaiguy makaiguy is offline
 
Join Date: May 2004
Location: Aiken, SC, USA
Posts: 150
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by dooch View Post
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
Not possible as written, but you could create a php page and adapt the code, I suppose. Would be an interesting project for somebody. You could use the two subroutines from this mod to move people into and out of the usergroups, but you'd have to write your own code to handle the choice made by the user.

Here's a tutorial on creating vB-based php pages:
https://vborg.vbsupport.ru/showthread.php?t=62164
Reply With Quote
  #59  
Old 09-24-2012, 11:30 PM
makaiguy's Avatar
makaiguy makaiguy is offline
 
Join Date: May 2004
Location: Aiken, SC, USA
Posts: 150
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:55 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04422 seconds
  • Memory Usage 2,298KB
  • Queries Executed 23 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (8)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete