vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Upon Email Verification, Choose Which Usergroup User Is Placed In? (https://vborg.vbsupport.ru/showthread.php?t=290434)

RedTurtle 11-11-2012 04:43 PM

Haha so the part about the "!$vbulletin->options['verifyemail']" I actually copied from your post a year ago here: https://vborg.vbsupport.ru/showpost....76&postcount=2 but am not sure what it means. I figured it meant that if the user no longer needs to verify their e-mail address (meaning they already have done it).

For the code that sets the user title to 'Deactivated', I believe it works like this--I have a custom usertitle for users in the usergroup Awaiting Moderation.

And I believe this code below changes the user to the Awaiting Moderation group (and then sets the usertitle):
PHP Code:

if ($vbulletin->usergroupcache["{$prevent_group}"]['usertitle'] != '')
                {
                    
$prevuserdm->set('usertitle'$vbulletin->usergroupcache["{$prevent_group}"]['usertitle']);
                    
$prevuserdm->set('customtitle'0);
                } 


kh99 11-11-2012 04:48 PM

Quote:

Originally Posted by RedTurtle (Post 2380295)
Haha so the part about the "!$vbulletin->options['verifyemail']" I actually copied from your post a year ago here: https://vborg.vbsupport.ru/showpost....76&postcount=2 but am not sure what it means. I figured it meant that if the user no longer needs to verify their e-mail address (meaning they already have done it).

Oh, I see. What it means is that "verify email" is turned on in the options. That post has code for a plugin using hook regitser_addmember_complete, so it's checking so that the code is only executed if you are not verifying the email.

So what if you try this:

Code:

if($user['usertitle'] == 'Deactivated')
{
$newusergroupid = 4;
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user
                      SET usergroupid = '".$newusergroupid."'
                      WHERE userid = '".$user['userid']);
}


kh99 11-11-2012 04:50 PM

I changed the above code after posting it, so make sure you try the current code.

RedTurtle 11-11-2012 05:05 PM

Thanks Kevin,

Using the newer code you put in, but it just seems to keep failing silently. Changes user to Registered Users rather than Users Awaiting Moderation.

And to confirm it is at register_activate_process.

Could it be that when the user confirms their email, they are being changed to the Registered Group (and thus losing the usertitle 'Deactivated') before our code goes into play and therefore it doesn't find any usertitle 'Deactivated' and doesn't do anything?

Would changing execution order make a difference here?

Thank you again.

kh99 11-11-2012 05:15 PM

Yeah, I think I'm the one who is confused, at least partly. That mod I linked to above uses hook register_addmember_complete, which is why using that method isn't working. I'll have to look at it more but I can't do it right now. If you wanted (and you haven't already), you could try looking at the code in register.php. You can see what's going on around the hook locations and hopefully figure out what needs to be done.

RedTurtle 11-12-2012 12:02 AM

Thank you again Kevin. I've been trying to make sense of this issue for the past couple of hours but not sure I'm getting anywhere.

I took your suggestion to look at register.php and from what I could tell, it sets the usergroup that the user will become a part of right at the registration section. Then once the email address is confirmed, it simply moves them to that usergroup that was set during registration.

Here is the part where it seems to determine usergroups near the beginning of register.php:

PHP Code:

// assign user to usergroup 3 if email needs verification
    
if ($vbulletin->options['verifyemail'])
    {
        
$newusergroupid 3;
    }
    else if (
$vbulletin->options['moderatenewmembers'] OR $vbulletin->GPC['coppauser'])
    {
        
$newusergroupid 4;
    }
    else
    {
        
$newusergroupid 2;
    }
    
// set usergroupid
    
$userdata->set('usergroupid'$newusergroupid);

    
// set languageid
    
$userdata->set('languageid'$vbulletin->userinfo['languageid']);

    
// set user title
    
$userdata->set_usertitle(''false$vbulletin->usergroupcache["$newusergroupid"], falsefalse); 

and then in this code below, it deals with the activation part of the process and it has a part where it says that we no longer need to check if the "moderate new members" setting is turned on or not since this is being handled during registration:

PHP Code:

if ($vbulletin->GPC['a'] == 'act')
{
    
$vbulletin->input->clean_array_gpc('r', array(
        
'u'        => TYPE_UINT,
        
'i'        => TYPE_STR,
    ));

    
$userinfo verify_id('user'$vbulletin->GPC['u'], 11);

    (
$hook vBulletinHook::fetch_hook('register_activate_start')) ? eval($hook) : false;

    if (
$userinfo['usergroupid'] == 3)
    {
        
// check valid activation id
        
$user $db->query_first("
            SELECT activationid, usergroupid, emailchange
            FROM " 
TABLE_PREFIX "useractivation
            WHERE activationid = '" 
$db->escape_string($vbulletin->GPC['i']) . "'
                AND userid = 
$userinfo[userid]
                AND type = 0
        "
);
        if (!
$user OR $vbulletin->GPC['i'] != $user['activationid'])
        {
            
// send email again
            
eval(standard_error(fetch_error('invalidactivateid'$vbulletin->session->vars['sessionurl'], $vbulletin->options['contactuslink'])));
        }

        
// delete activationid
        
$db->query_write("DELETE FROM " TABLE_PREFIX "useractivation WHERE userid=$userinfo[userid] AND type=0");

        
/*
        This shouldn't be needed any more since we handle this during registration
        if ($userinfo['coppauser'] OR ($vbulletin->options['moderatenewmembers'] AND !$userinfo['posts']))
        {
            // put user in moderated group
            $user['usergroupid'] = 4;
        }*/

        
if (empty($user['usergroupid']))
        {
            
$user['usergroupid'] = 2// sanity check
        
}

        
// ### DO THE UG/TITLE UPDATE ###

        
$getusergroupid iif($userinfo['displaygroupid'] != $userinfo['usergroupid'], $userinfo['displaygroupid'], $user['usergroupid']);

        
$user_usergroup =& $vbulletin->usergroupcache["$user[usergroupid]"];
        
$display_usergroup =& $vbulletin->usergroupcache["$getusergroupid"];

        
// init user data manager
        
$userdata =& datamanager_init('User'$vbulletinERRTYPE_STANDARD);
        
$userdata->set_existing($userinfo);
        
$userdata->set('usergroupid'$user['usergroupid']);
        
$userdata->set_usertitle(
            
$user['customtitle'] ? $user['usertitle'] : '',
            
false,
            
$display_usergroup,
            (
$user_usergroup['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canusecustomtitle']) ? true false,
            (
$user_usergroup['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['cancontrolpanel']) ? true false
        
);

        require_once(
DIR '/includes/functions_ranks.php');
        if (
$user['userid'] == $vbulletin->userinfo['userid'])
        {
            
$vbulletin->userinfo['usergroupid'] = $user['usergroupid'];
            
$vbulletin->userinfo['displaygroupid'] = $user['usergroupid'];
        }

        
// see 3.6.x bug #176
        //$userinfo['usergroupid'] = $user['usergroupid'];

        
($hook vBulletinHook::fetch_hook('register_activate_process')) ? eval($hook) : false;

        if (
$userinfo['coppauser'] OR ($vbulletin->options['moderatenewmembers'] AND !$userinfo['posts']))
        {
            
// put user in moderated group
            
$userdata->save();
            eval(
standard_error(fetch_error('moderateuser'$userinfo['username'], fetch_seo_url('forumhome', array())), ''false));
        }
        else
        {
            
// activate account
            
$userdata->save();

            
// rebuild stats so new user displays on forum home
            
require_once(DIR '/includes/functions_databuild.php');
            
build_user_statistics();

            
$username unhtmlspecialchars($userinfo['username']);
            if (!
$user['emailchange'])
            {
                if (
$vbulletin->options['welcomemail'])
                {
                    eval(
fetch_email_phrases('welcomemail'));
                    
vbmail($userinfo['email'], $subject$message);
                }

                
$userdata->send_welcomepm();
            }

            if (
$user['emailchange'])
            {
                eval(
standard_error(fetch_error('emailchanged'htmlspecialchars_uni($userinfo['email'])), ''false));
            }
            else
            {
                
                eval(
standard_error(fetch_error('registration_complete'$userinfo['username'], 
                    
$vbulletin->session->vars['sessionurl'], fetch_seo_url('forumhome', array())), ''false));
            }
        }
    }
    else
    {
        if (
$userinfo['usergroupid'] == 4)
        {
            
// In Moderation Queue
            
eval(standard_error(fetch_error('activate_moderation'), ''false));
        }
        else
        {
            
// Already activated
            
eval(standard_error(fetch_error('activate_wrongusergroup')));
        }
    }




So I guess my thing is that since the usergroup is already being defined during registration and there's no checks for which usergroup to put the user into at activation, is there still a way I can hook into the activation process and move a user to the desired group, or is there any other process right after activation that I can use to do this?

Thank you so much for continuously helping! :D


All times are GMT. The time now is 07:37 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.01810 seconds
  • Memory Usage 1,817KB
  • 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
  • (3)bbcode_php_printable
  • (1)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
  • (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