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-14-2006 05:58 AM

I've updated to version 1.03. When trying to adapt for situations other than the narrow password-in-custom-field control, some modifications were necessary, as the 1.02 code did not deal well with situations where no radio button choice had yet been made by the user.

[S]Code in first post reflects latest version 1.03.[/S]

[S]See also the second post which has been updated with working code to use radio buttons in custom profile field to allow user to select one of several usergroups.[/S]

All Code now included in download file.

makaiguy 04-14-2006 06:03 AM

Quote:

Originally Posted by trigon
i want to check if the user has in "field5" "women", then move him to usergroup "20". If he has "men", let him in this group.
Maybe you can wrote me a plugin, cause its to confusing for me what here is written, sorry.

See the second post. The revised code there fits your situation exactly. Set up your custom field in the profile as a single choice radio button, with the two 'options' being 'men' and 'women'.

makaiguy 04-14-2006 03:27 PM

Version 1.03.1 now in place. See first and second posts in thread.

makaiguy 04-16-2006 11:12 PM

Version 1.04 is now in place. It adds a check to prevent modifying the user's PRIMARY usergroup.

trigon 04-18-2006 11:35 PM

If i activate the plugin, then this error comes: Fatal error: Call to undefined function: outgroup() in /home/********l/public_html/forum/global.php(349) : eval()'d code on line 86

If i deactivate, everything looks good.
Btw, the plugin doesnt work for me, maybe you can take a look on it:
I have three fields, one for women (written in german/turkish)
one for men, and one for "no i dont want to give this info", also in german/turkish. The only with a new usergroup is the first (groupid 20)

makaiguy 04-19-2006 03:35 AM

Quote:

Originally Posted by trigon
If i activate the plugin, then this error comes: Fatal error: Call to undefined function: outgroup() in /home/********l/public_html/forum/global.php(349) : eval()'d code on line 86

If i deactivate, everything looks good.
Btw, the plugin doesnt work for me, maybe you can take a look on it:
I have three fields, one for women (written in german/turkish)
one for men, and one for "no i dont want to give this info", also in german/turkish. The only with a new usergroup is the first (groupid 20)

Sorry, this is my fault. In 1.04 I changed the function names but failed to update to the new names in the code that called them. Replace the 'Do the work' section with:

PHP Code:

// 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, add to usergroups
          
if ($fieldval == $choice_text[$iii])
          {
            
$ugarr IntoGroup($ugarr$ug[$iii], $userid);
          } 
          
// If we have no match, remove from usergroups
          
else
          {
            
$ugarr OutOfGroup($ugarr$ug[$iii], $userid);      
          } 
          
$iii++; 
      } 
    }  
  } 

I've edited all three scripts in the first and second posts in the thread with this correction.

Also note that you have a problem with the third option you entered. That should be
Code:

  // THIRD radio button option     
    // Text shown in radio button for option
        $choice_text[2] = 'keine Angabe/Bilgi yok';
    // Associated usergroup number 
        $ug[2] = '2';


trigon 04-19-2006 10:16 PM

Ok, now it works, any hint to make it for the primary usergroup? Cause i want to move the primary usergroup, not the secondary ones.

makaiguy 04-19-2006 10:25 PM

All code has been removed from the first two posts in this thread. The latest versions of everything will always be located in the downloadable text file.

makaiguy 04-19-2006 10:46 PM

Quote:

Originally Posted by trigon
Ok, now it works, any hint to make it for the primary usergroup? Cause i want to move the primary usergroup, not the secondary ones.

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
              "
);
          }
        } 


The Chief 04-19-2006 10:54 PM

screen shots?


All times are GMT. The time now is 12:51 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.01254 seconds
  • Memory Usage 1,779KB
  • 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_code_printable
  • (2)bbcode_php_printable
  • (3)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