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

Reply
 
Thread Tools Display Modes
  #1  
Old 11-10-2012, 05:41 AM
RedTurtle's Avatar
RedTurtle RedTurtle is offline
 
Join Date: May 2006
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Upon Email Verification, Choose Which Usergroup User Is Placed In?

Is it possible to have a plugin that hooks into the vBulletin email verification system and does the following:

Based upon matching a word in a user's User Title field, upon the user verifying their email address, instead of the user being placed into the Registered Users usergroup, being placed instead in a different usergroup?

For example if I have a user's User Title is "Deactivated", I'd like the person to be moved to a certain usergroup after they have finished verifying their email rather than going to Registered Users.

I found this post by the awesome kh99 from about a year ago here: https://vborg.vbsupport.ru/showpost....76&postcount=2 but I'm not sure how I could adapt this code to only work when a user has user title "Deactivated".

Code:
if(!$vbulletin->options['verifyemail'])
{
    // do some check to figure out usergroupid (X)
    $newusergroupid = X;
    $vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "useractivation 
                                                    SET usergroupid = '".$newusergroupid."' 
                                                    WHERE activationid = '".$activateid."' LIMIT 1 ");
}
Any help would be very much appreciated. Thank you for reading.

--------------- Added [DATE]1352581404[/DATE] at [TIME]1352581404[/TIME] ---------------

I guess more specifically my question would be does anyone know how to use an if conditional in the plugin to test the value of the User Title field?

--------------- Added [DATE]1352589399[/DATE] at [TIME]1352589399[/TIME] ---------------

Update:

Tried this code here as a plugin, at hook register_addmember_process and at register_activate_process but doesn't work (no error message either).

Code:
if(!$vbulletin->options['verifyemail'])
{
$usertitle_check = $db->query_first("SELECT usertitle from ".TABLE_PREFIX."user where userid = ".$vbulletin->userinfo['userid']);
			if ($usertitle_check == "Deactivated")
			{
			$userdata->set('usergroupid', 4);
			}
}
What I'm trying to accomplish is that after a user registers, I have them placed in a certain usergroup. Then if their e-mail address is incorrect and their email bounces, I have them placed in a different usergroup. Once they change their email address and confirm their account, I would like them to go back to the original usergroup they were in before, instead of just going to Registered Users by default.
Reply With Quote
  #2  
Old 11-11-2012, 02:57 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There's this mod that does something similar: www.vbulletin.org/forum/showthread.php?t=242068 It looks like what it does is changes the usergroupid in the user table directly.

Do you have code somewhere that sets the User Title to 'Deactivated' or are you doing that manually? I'm asking because if it's begin done in code, what you might be able to do is change the usergroupid field in the useractivation table, in any row where the userid matches.

To answer your question about checking the user title in a plugin, I think at register_activate_process you'd check $user['usertitle'].
Reply With Quote
  #3  
Old 11-11-2012, 03:06 PM
RedTurtle's Avatar
RedTurtle RedTurtle is offline
 
Join Date: May 2006
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you so much for responding!

I have this mod which currently moves any user who it detects as already having an account on the forum to the Usergroup of Users Awaiting Moderation. I have a Custom Title set for that usergroup of 'Deactivated'.

I then have another mod that moves any account that has a false email address to the Users Awaiting Email Verification group.

So what happens currently is that if someone creates a duplicate account with a false e-mail address, they are first placed in the Awaiting Moderation group but then when their email bounces they are automatically moved to the Awaiting Email Verification group. Now if they change their email address and confirm it, they'll be moved to Registered Users, instead of being moved back to the Awaiting Moderation group.

Having them instead move back to Awaiting Moderation is what I'm trying to accomplish by having any user with usertitle 'Deactivated' moved back to Awaiting Moderation upon email confirmation.

So am not sure exactly how I should do that. Would I check usertitle with $user['usertitle'] and then use this code?

Code:
if(!$vbulletin->options['verifyemail'] AND $user['usertitle'] == 'Deactivated')
{
$newusergroupid = 4;
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "useractivation 
                                                    SET usergroupid = '".$newusergroupid."' 
                                                    WHERE activationid = '".$activateid."' LIMIT 1 ");
}
Thank you!
Reply With Quote
  #4  
Old 11-11-2012, 03:09 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, that's what I was thinking, but I haven't tested it or anything.

Edit: Well, actually what I was thinking is that you'd do that database update wherever it is that you're now setting the user title to 'Deactivated', then you might not have to do anything when the actual activation happens.
Reply With Quote
  #5  
Old 11-11-2012, 03:17 PM
RedTurtle's Avatar
RedTurtle RedTurtle is offline
 
Join Date: May 2006
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ah thanks Kevin, but that seems to just fail silently and doesn't change the usergroup. Still having the user end up in Registered Members after email verification.

Not sure if my check for usertitle is not working, or my database write isn't working.

Any steps you could recommend on figuring out which part is failing? Or maybe I'm hooking at the wrong part?

Thank you again for your time in helping me solve all the weird issues I come up with.
Reply With Quote
  #6  
Old 11-11-2012, 03:23 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, I answered too quickly (then I edited my post above but you may have missed it). I don't know if that code would work at register_activate_process, what I was suggesting is that you use that database update line at the same place where you're now setting the user title to 'Deactivated'.
Reply With Quote
  #7  
Old 11-11-2012, 03:55 PM
RedTurtle's Avatar
RedTurtle RedTurtle is offline
 
Join Date: May 2006
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok so looking at the way that the mod that moves users to the awaiting moderation usergroup works, it hooks at register_addmember_complete. It calls an external file via this code:

Code:
if ($vbulletin->options['madp_prevention'] >= 0 AND ($vbulletin->options['madp_prevention'] < 4 OR $vbulletin->options['madp_silent_mode']))
{
	require_once(DIR . '/madp/prevention.php');
}
else
{
	require_once(DIR . '/madp/set.php');
}
Then in prevention.php, the part that seems to be doing the usergroup changing is this:

PHP Code:
if (!$vbulletin->options['madp_silent_mode'])
        {
            
// we caught multiple(s)
            
$user $vbulletin->userinfo;

            
$prevuserdm =& datamanager_init('User'$vbulletinERRTYPE_SILENT);
            
$prevuserdm->set_existing($user);
            
            if (
$prevent_set)
            {
                
$prevuserdm->set('usergroupid'$prevent_group);
                
$prevuserdm->set('displaygroupid'0);

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

                
$peventmsg $vbphrase['madp_message_prevented'];
            }
            else
            {
                
$peventmsg $vbphrase['madp_message_error'];
                
$verbose_msgs += ERROR_USERGROUP_CACHE;
            }

            
$prevuserdm->save();
            unset(
$prevuserdm);
        } 
If I try my code at register_addmember_complete, it doesn't seem to work.

My code:

Code:
if(!$vbulletin->options['verifyemail'] AND $user['usertitle'] == 'Deactivated')
{
$newusergroupid = 4;
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "useractivation 
                                                    SET usergroupid = '".$newusergroupid."' 
                                                    WHERE activationid = '".$activateid."' LIMIT 1 ");
}
Could it have anything to do with my trying to do a SQL write whereas the other plugin doesn't seem to be doing that? Sorry if that is a stupid question.
Reply With Quote
  #8  
Old 11-11-2012, 04:21 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't know what mod that is. But I think I probably confused things by mentioning a couple different possibilities. I was suggesting two possible approaches (of whihc you'd want to choose only one): 1) change the useractivation table in the same place you're currently setting the user title, in which case you don't need a plugin to do anything when the actual activation happens because it wil use the usergroup from the useractivation table. Or 2) use a plugin at hook register_active_process and check the user title field and set the usergroupid in the user table, like the mod I linked to above. The code for that would be something like:

Code:
if(!$vbulletin->options['verifyemail'] AND $user['usertitle'] == 'Deactivated')
{
$newusergroupid = 4;
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user 
                       SET usergroupid = '".$newusergroupid."' 
                       WHERE userid = '".$user['userid']);
}
Reply With Quote
  #9  
Old 11-11-2012, 04:36 PM
RedTurtle's Avatar
RedTurtle RedTurtle is offline
 
Join Date: May 2006
Location: California
Posts: 205
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Kevin.

Going with Option #2, and trying that code you just included above at register_activation_process doesn't seem to work. I would prefer to get this to work since the code seems so much "neater" and easier to implement. Any way I can break this out to test the individual components to see what's failing?

Do you think Option #1 is the only way to get this to work? I'm a little hesitant to go with Option #1 just because I don't fully understand it I suppose. When you say "change the useractivation table in the same place you're currently setting the user title" does that mean edit this modification's code to add something near the code where it sets the usergroup to the awaiting moderation group?

Thank you again for all your patience and time.
Reply With Quote
  #10  
Old 11-11-2012, 04:39 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, looking at the above code again, I don't know about the "!$vbulletin->options['verifyemail']" part, I assumed you knew why that was there. Maybe try taking out that check?

I was asking above if you had code that set the user title to 'Deactivated' - what code is doing that? If you can find where that's done, then you should be able to add the update of the useractivation table at that same point.
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:36 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04471 seconds
  • Memory Usage 2,280KB
  • 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
  • (6)bbcode_code
  • (1)bbcode_php
  • (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
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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