vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.5 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=113)
-   -   AUTOJOIN - Auto-entry in membergroup via field in profile (https://vborg.vbsupport.ru/showthread.php?t=111870)

makaiguy 06-06-2006 03:29 AM

Amazing. It worked right out of the box with no debugging at all. Must have held my mouth just right while coding, or something. Anyhow, here's what to use as the control in place of the ones in the downloadable autojoin.txt file:
PHP Code:

// Add or remove user from secondary usergroup
// according checkboxes selected in user's profile
// Ver 1.4

global $vbulletin;

// Enter values in the strings below for your forum
  // number of the custom field containing your checkboxes
        
$boxes_field 'fieldX';
  
// Usergroup number for FIRST checkbox option
        
$ug[0] = 'X';                     
  
// Usergroup number for SECOND checkbox option 
        
$ug[1] = 'Y';                     
  
// add additional checkbox options as needed 

// You need make no changes below here
                         
// Derive additional needed variables
  // userid of user
        
$userid = ($vbulletin->userinfo['userid']);                           
  
// current usergroups as array
        
$ugarr explode(',' , (''.$vbulletin->userinfo['membergroupids']));  
  
// boxes selected
        
if ($vbulletin->userinfo[$boxes_field] == '')
        {
           
$fieldval 0;
        }   
        else
        {
           
$fieldval $vbulletin->userinfo[$boxes_field];
        } 

// Do the work
$iii 0;
foreach (
$ug as $value
{
   if (
$fieldval pow(2$iii))
   {
      
$ugarr IntoGroup($ugarr$ug[$iii], $userid);
   } 
   else
   {
      
$ugarr OutOfGroup($ugarr$ug[$iii], $userid);      
   } 
   
$iii++; 


.. then just add in the code for the two functions as in the downloaded autojoin.txt file.

I'll get this added to the autojoin.txt file real soon now ...

[Edit:] Has now been added to the downloadable autojoin.txt file, as version 1.05.

cavyspirit 08-26-2006 04:01 PM

I really need this in 3.6. First attempt isn't working.

makaiguy 08-31-2006 10:03 PM

Quote:

Originally Posted by cavyspirit
I really need this in 3.6. First attempt isn't working.

I haven't updated my board to 3.6 yet. But since this hack is very important to my board's operation, you can be sure I'll be updating it to work with 3.6 in the near future.

cavyspirit 11-12-2006 10:29 PM

I now need to make this work on the regular Birthday field.

I want one secondary user group assigned if the member is under 16 and another secondary user group assigned if the member is under 21. Is this possible? Can someone suggest the code change?

Thanks

RFViet 11-14-2006 01:49 PM

Quote:

Originally Posted by The Chief (Post 954573)
screen shots?

The same question !!

makaiguy 11-14-2006 10:35 PM

Quote:

Originally Posted by RFViet (Post 1117097)
The same question !!

The same answer: There are no screen shots because nothing is displayed onscreen. It just sets the user's secondary usergroups when he logs on, according to whatever you have set up.

Cocko 11-15-2006 06:30 PM

any product scripts .xml out for 3.6x ?

makaiguy 12-07-2006 01:31 PM

I've finally started playing with getting my board updated to 3.6 (3.6.4, actually).

AutoJoin has continued to work for me without modification to the original 3.5.4 installation.

salata 12-08-2006 01:42 AM

can you have them not enter the password at every login in? basically have them choose what usergroup they belong to at registration, I.E. if i had separate sections for men and women

makaiguy 12-08-2006 01:57 AM

Quote:

Originally Posted by salata (Post 1134248)
can you have them not enter the password at every login in? basically have them choose what usergroup they belong to at registration, I.E. if i had separate sections for men and women

The idea of this addon is that you create a special field in their profile. They enter the required value in this field in the profile one time, and on every subsequent login it checks for the required value in that profile field, and puts them into or out of the specified secondary user group.

[Edited to add] Code is provided to do this via several different formats for the custom profile field. You may do it as:
  1. Password for single usergroup (alternative to password-protected forum where user must enter password for every session - this way they only enter into their profile one time. Set your forum persmissions to only admit members of the specified 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

makaiguy 12-08-2006 04:08 PM

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.

everd 12-08-2006 05:54 PM

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

makaiguy 05-23-2007 12:08 AM

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.

Mum 05-29-2007 07:21 AM

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

makaiguy 05-29-2007 10:36 PM

Quote:

Originally Posted by Mum (Post 1256695)
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

dooch 06-07-2007 03:34 PM

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

makaiguy 06-07-2007 08:21 PM

Quote:

Originally Posted by dooch (Post 1263336)
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

makaiguy 09-24-2012 11:30 PM

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.


All times are GMT. The time now is 01:17 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01289 seconds
  • Memory Usage 1,811KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (18)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete