The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Plugin Vbulletin Variable for Usergroup ID
Hello everyone,
I have wrote a simple plugin script which runs under hook location login_verify_success which is intended to write the current users IP & Host to another MYSQL database on the same server as vbulletin. The code ive formulated is pretty simple to me and working in principle, but when I wanted to add a check for vbulletin usergroups, it all went weird. Basically as you will see in my plugin script, I want to check the usergroup of the member who has logged in successfully, and if they match one defined in the array, then run the MYSQL queries dependant on the output. However to the point, the original variable I tried was the following: Code:
if ($vbulletin->userinfo['usergroupid'] == 'x' || 'y' || 'z') { //Some Code } So I tried another way I knew of: Code:
if ( is_member_of($vbulletin->userinfo, explode(',', X,Y,Z)) { //Some Code } Heres the full script: Code:
// MYSQL Server Domain $mysqldomain = "DOMAIN"; // MYSQL Server Username $mysqluser = "USER"; // MYSQL Server Password $mysqlpass = "PASS"; // MYSQL Database Name $mysqldb = "TABLE"; mysql_connect($mysqldomain, $mysqluser, $mysqlpass) or die(mysql_error()); mysql_select_db($mysqldb) or die(mysql_error()); // Define Key Variables $ip = $_SERVER['REMOTE_ADDR']; $hostname = gethostbyaddr($ip); if ( is_member_of($vbulletin->userinfo, explode(',', 9,10,11,19,12,24,20,13)) { // MYSQL QUERIES }else{ // DIFFERENT MYSQL QUERIES } On a side note, I have used the $vbulletin->userinfo['userid'] variable in the MYSQL queries and there are no problems. Thanks for any help in advance. Matt |
#2
|
||||
|
||||
No need to do the explode:
PHP Code:
|
#3
|
|||
|
|||
Your explode syntax won't work because you don't even have a string as a parameter.
Is there a reason you're using define database connections when the database is defined inside the $vbulletin class? Your use of the OR operator is also incorrect. Try checking their use at php.net |
#4
|
||||
|
||||
Quote:
The reason why I am defining the database connection info again is due to the fact the database is different to the one I use for vbulletin and which is obviously called from config.php. The server is the same (domain) but the connection info is different due to that factor. Could you also define what you mean by the OR operator being incorrect? I assume you are referring to the "or die mysql_error()". It has always worked for me :s Could anyone offer an explanation as to why the first conditional I tried didnt work fully? Thanks to Lynne and Bellardia EDIT: This still didnt fix my issue after using Lynne's code, but then I noticed there was a missing closing bracket. All is working as expected, thank you! Matt |
#5
|
|||
|
|||
Although not in your main code, you posted this
Code:
if ($vbulletin->userinfo['usergroupid'] == 'x' || 'y' || 'z') Code:
if ($vbulletin->userinfo['usergroupid'] == 'x' || $vbulletin->userinfo['usergroupid'] == 'y' || $vbulletin->userinfo['usergroupid'] == 'z') |
#6
|
||||
|
||||
Argh! I need to double-check my parenthesis before posting! Sorry about that.
|
#7
|
||||
|
||||
Quote:
PHP Code:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|