Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #11  
Old 11-11-2012, 04:43 PM
RedTurtle's Avatar
RedTurtle RedTurtle is offline
 
Join Date: May 2006
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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);
                } 
Reply With Quote
  #12  
Old 11-11-2012, 04:48 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by RedTurtle View Post
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']);
}
Reply With Quote
  #13  
Old 11-11-2012, 04:50 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I changed the above code after posting it, so make sure you try the current code.
Reply With Quote
  #14  
Old 11-11-2012, 05:05 PM
RedTurtle's Avatar
RedTurtle RedTurtle is offline
 
Join Date: May 2006
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #15  
Old 11-11-2012, 05:15 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #16  
Old 11-12-2012, 12:02 AM
RedTurtle's Avatar
RedTurtle RedTurtle is offline
 
Join Date: May 2006
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:18 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.05802 seconds
  • Memory Usage 2,292KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (3)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete