vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Users being removed from Usergroups (https://vborg.vbsupport.ru/showthread.php?t=159893)

Murty 10-14-2007 07:27 AM

OK, well here is the code.

This is the .php file under /includes
PHP Code:

<?php

foreach (explode(',',$userdata->fetch_field('membergroupids')) as $pg_group)
{
    
$pg_groupids[$pg_group] = $pg_group;
}
foreach (
explode("\n",$vbulletin->options['profile_groups']) as $pg_triple)
{
    list(
$pg_field,$pg_groupid,$pg_yes) = split(';',trim($pg_triple));
    if (
$pg_field and $pg_groupid)
    {
        if (!
$pg_yes)
        {
            
$pg_yes 'Yes';
        }
        if (
$userdata->userfield[$pg_field] == $pg_yes)
        {
            if (!(
$pg_groupids[$pg_groupid]))
            {
                
$pg_groupids[$pg_groupid] = $pg_groupid;
            }
        }
        else
        {
            if (
$pg_groupids[$pg_groupid])
            {
                
$pg_groupids[$pg_groupid] = 0;
            }
        }
    }
}
foreach (
$pg_groupids as $pg_groupid => $pg_value)
{
    if (
$pg_value == 0)
    {
        continue;
    }
    if (
$pg_membergroups)
    {
        
$pg_membergroups .= ',' $pg_value;
    }
    else
    {
        
$pg_membergroups $pg_value;
    }
}
$userdata->set('membergroupids'$pg_membergroups);

?>

There are also some plugins and an admincp thing if you want them?

Murty 10-15-2007 07:39 AM

I hate having to bump all the time, but i really need some help with this.
Thanks

Lynne 10-15-2007 04:37 PM

It is sometimes hard to just jump in and 'read' someone else's code which is why you probably aren't getting a whole lot of help with this. Maybe explain what you are trying to do with that script and people can think about how they would go about it and then 'read' what the problems are with how you went about it.

Murty 10-15-2007 11:36 PM

OK, fair enough.

Just to refresh peoples minds, my problem is that users are being removed from their usergroup randomly.

Well basically what this mod does is when a user registers, they select 'male' or 'female' (setup in 'user profile field manager'). Then depending whether they select 'male' or 'female' it puts them in the specified user group that I define.

There is an option in 'admincp' where i can define these settings.

This is what it looks like:
field5;9;Female
field5;10;Male

So 'field5' is the profile field; '9' or '10' are the usergroups; 'female' or 'male' are the options that the user can select at registration.

Note: the user can only select their gender AT registration, nowhere else.

There are also 2 plugins.
One has a hook in the 'register_addmember_process' location, with php code:
PHP Code:

require_once(DIR '/includes/profile_groups.php'); 

The other one has a hook in the 'profile_updateprofile' location, with the php code:
PHP Code:

require_once(DIR '/includes/profile_groups.php'); 


(That "/includes/profile_groups.php" is the code a couple posts above.)

I'm not 100% sure, but I'm not sure if there should be a plugin at the 'profile_updateprofile' location...

Marco van Herwaarden 10-16-2007 07:06 AM

That sounds like a logical explanation. If your members can only enter their gender at registration time, then there is no use to also run it when they update their profile. I can imagine that this automagically changes the usergroup.

But i guess this could be easy tested.

Murty 10-16-2007 08:09 AM

Well i've turned it off, ill see how it goes.
Thanks for your advice marco.


All times are GMT. The time now is 09:50 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.01052 seconds
  • Memory Usage 1,742KB
  • 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
  • (3)bbcode_php_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
  • (6)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