The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
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 "); } --------------- 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); } } |
#2
|
|||
|
|||
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']. |
#3
|
||||
|
||||
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 "); } |
#4
|
|||
|
|||
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. |
#5
|
||||
|
||||
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. |
#6
|
|||
|
|||
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'.
|
#7
|
||||
|
||||
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'); } PHP Code:
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 "); } |
#8
|
|||
|
|||
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']); } |
#9
|
||||
|
||||
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. |
#10
|
|||
|
|||
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. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|