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 04-19-2006 11:02 PM

Quote:

Originally Posted by The Chief
screen shots?

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.

trigon 04-20-2006 12:05 AM

Quote:

Originally Posted by makaiguy
In AdminCP, when you try to add a person into a secondary usergroup which also happens to be their current primary usergroup it won't let you, so I wrote that same restriction into the code for this plugin.

If you want to change only the primary usergroup, your query needs to update usergroupid instead of membergroupids. Also, since there can only be one primary usergroup, it is a simpler operation because you just reset usergroupid to the new value and don't have to worry about leaving any other primary usergroups alone.

This is untested, but it ought to be at least close to what you need:
PHP Code:

      // Place user in/out of selected single PRIMARY
      // usergroup, according to selection made in profile, via
      // custom radio button field. ver 1.04

      // **************  UNTESTED CODE ****************
      
      // Enter values in the strings below for your forum
        // custom field containing your radio button
           
$radio_field 'fieldX';
        
// FIRST radio button option 
           // Text shown in radio button for option
              
$choice_text[0] = 'Choice1';
           
// Associated usergroup number   
              
$ug[0] = 'XX';                     
         
// SECOND radio button option 
           // Text shown in radio button for option
              
$choice_text[1] = 'Choice2';
           
// Associated usergroup number   
              
$ug[1] = 'YY';                     
        
// add additional radio button choices as needed 
      
      // You don't need to enter anything below here                         
      // Derive additional needed variables
        
$userid = ($vbulletin->userinfo['userid']); 
        
$pgrp $vbulletin->userinfo['usergroupid'])); 
        
$new_pgrp $pgrp;
        
$fieldval $vbulletin->userinfo[$radio_field];        
      
      
// Do the work  
        // Proceed only if there is a user choice
        
if ($fieldval != '')
        {
          if(
$ug[0] != '')
          {
            
$iii 0;
            
// Check user choice against possible options
            
foreach ($choice_text as $value
            {
                
// If we have a match, set as new primary usergroup
                
if ($fieldval == $choice_text[$iii])
                {
                  
$new_pgrp $ug[$iii];
                } 
                
$iii++; 
            } 
          }
          
// if new group different than current group 
          
if ($new_gprp != $pgrp)
          {
            
// Put updated usergroup into database
            
$updatefields $vbulletin->db->query("
              UPDATE user
              SET usergroupid='
$new_gprp'
              WHERE userid=
$usrid
              "
);
          }
        } 



So i must only use this one? or must i something replace from the old one?
(the values i must change, that i have understand ;))

makaiguy 04-20-2006 12:09 AM

Quote:

Originally Posted by trigon
So i must only use this one? or must i something replace from the old one?
(the values i must change, that i have understand ;))

That one only. Edit in your values, and add the third radio button values as before.

trigon 04-20-2006 02:48 AM

thx, m8, installed it, now i must wait until my girls log in :D

makaiguy 04-20-2006 02:50 AM

Quote:

Originally Posted by trigon
thx, m8, installed it, now i must wait until my girls log in :D

You don't have a fake account to test stuff like this on?

trigon 04-20-2006 02:57 AM

tried with a fake account, but it doesnt go. take a look at the code plz:
// Place user in/out of selected single PRIMARY
// usergroup, according to selection made in profile, via
// custom radio button field. ver 1.04

// ************** UNTESTED CODE ****************

// Enter values in the strings below for your forum
// custom field containing your radio button
$radio_field = 'field5';
// FIRST radio button option
// Text shown in radio button for option
$choice_text[0] = 'Weiblich/Bayan';
// Associated usergroup number
$ug[0] = '20';
// SECOND radio button option
// Text shown in radio button for option
$choice_text[1] = 'Männlich/Erkek';
// Associated usergroup number
$ug[1] = '2';
// THIRD radio button option
// Text shown in radio button for option
$choice_text[2] = 'keine Angabe/Bilgi yok';
// Associated usergroup number
$ug[2] = '2';
// add additional radio button choices as needed

// You don't need to enter anything below here
// Derive additional needed variables
$userid = ($vbulletin->userinfo['userid']);
$pgrp = $vbulletin->userinfo['usergroupid']));
$new_pgrp = $pgrp;
$fieldval = $vbulletin->userinfo[$radio_field];

// Do the work
// Proceed only if there is a user choice
if ($fieldval != '')
{
if($ug[0] != '')
{
$iii = 0;
// Check user choice against possible options
foreach ($choice_text as $value)
{
// If we have a match, set as new primary usergroup
if ($fieldval == $choice_text[$iii])
{
$new_pgrp = $ug[$iii];
}
$iii++;
}
}
// if new group different than current group
if ($new_gprp != $pgrp)
{
// Put updated usergroup into database
$updatefields = $vbulletin->db->query("
UPDATE user
SET usergroupid='$new_gprp'
WHERE userid=$usrid
");
}
}

makaiguy 04-20-2006 04:26 AM

Quote:

Originally Posted by trigon
tried with a fake account, but it doesnt go. take a look at the code plz:

We've derailed this topic long enough. Taking this to PM.

SHalliday 06-04-2006 10:52 PM

This seems like an awesome hack. So far however I have not been able to get it to work like what I need. After spending the entire day trying different variations I finally decided to ask the experts and post here.

I want members to be able to select one or more public groups to join. I first tried using a multiple-selection checkbox and after not being able to get that to work I setup 7 different single radio button fields and created a different single radio button plugin for each field. That did not work either.

My question is --> Will this work with a multiple-selection checkbox?

I want to create a multiple-selection checkbox and allow members to check off the groups they would like to be a member of. Those that are not checked off, I would like them to be removed from. Can this hack be used to accomplish this?

Appreciate any help and/or assistance you can provide.

Thank you.

makaiguy 06-06-2006 02:38 AM

Quote:

Originally Posted by SHalliday
My question is --> Will this work with a multiple-selection checkbox?

Sure. It just requires a custom control to interract with the multiple-selection checkbox field. I'm in the middle of sketching it out now. Will be back in a day or two (or sooner if all goes exceptionally well and nothing blows up on my own bbs in the meanwhile).

SHalliday 06-06-2006 03:09 AM

Thank you very much. Looking forward to your custom control script for multiple-selection checkbox field.


All times are GMT. The time now is 03:31 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.01066 seconds
  • Memory Usage 1,772KB
  • 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
  • (4)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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