PDA

View Full Version : PHP / Vbulletin Interaction


dearinfinity
06-22-2010, 11:26 PM
Hi,

What are the variables for userid, etc for PHP?

How would I write a PHP script that is as follows

if user is a member of usergroup 1:

do this

else:

do this
?

How do I get PHP to pull user data, and interact? Thanks

bailz66
06-22-2010, 11:31 PM
do you want php to pull data from the database or a session?

If its from a session use the

$vbulletin->userinfo

$vbulletin->userinfo['username'] will give you the username i havent had to do anything with usergroups but should be pretty easy to work out

if its from the database should be pretty easy

dearinfinity
06-23-2010, 04:34 AM
hi, thanks for the reply,

so any idea on how I could get a script to change the logged in user's USERGROUP to a number when it is run?

noppid
06-23-2010, 04:58 AM
Hi,

What are the variables for userid, etc for PHP?

How would I write a PHP script that is as follows

if user is a member of usergroup 1:

do this

else:

do this
?


How do I get PHP to pull user data, and interact? Thanks

Try something like this...

<vb:if condition="is_member_of($bbuserinfo, 1)">Do this<vb:else />Or else this</vb:if>

dearinfinity
06-23-2010, 05:03 AM
can I put that directly in a .php file and it will still execute?

consolegaming
06-23-2010, 07:17 AM
No. I don't think anyone understands what you were asking lol. That last bit of code is for the templates within vB and that other bit of code would only work if the userinfo array has been populated.

There will be a lot of threads on this but the usual way to integrate is to include vb's global.php file (like I said there will be a lot of threads about this so do a search - "external php vbulletin" or something in google). This will populate the variables you need and then you can start using the userinfo array. And that array will contain the usergroupid's for that user. But a user can be in several usergroups so you'll need to explode (explode function) the field using commas as your separator. And then check if the usergroup you are looking for is in that array (in_array function).

I myself handle it all manually. i.e. I check whether the user is logged in or not, if so then I do a mysql query on the user table to pull back the user's information and load that into an array of my own.

dearinfinity
06-23-2010, 11:27 AM
thanks a ton!!