PDA

View Full Version : Change a user's style / template using php


30et
07-27-2009, 01:40 AM
Hi there

I want to write a page that changes the template a user is using, and then redirects them to another url (outside of vbulletin) but in the same domain so that when they return to vbulletin they get the new template.

I thought I could do this on a php page - just change the template setting and then redirect their browser. But I can't figure out how or where the template setting for a user is stored.

I see that there is a cookie called 'bbstyleid' which has the template's style id.
And in the database there is a field in the 'user' table which is 'styleid'.
And also there is another table called 'session' which has a field named 'styleid'.

I have tried to modify the fields in the tables but they don't seem to take effect. And I have also tried changing the cookie value using

setcookie("bbstyleid", "12345");

But it doesn't seem to change?

Does anyone have a suggestion? :confused:

Plus

Dismounted
07-27-2009, 06:23 AM
The user's cookie takes priority, then its the user options field, then board default.

Have you checked that the cookie is indeed being set?

30et
07-28-2009, 10:17 PM
The cookie is already set by the user's preferences, but I can't seem to change it using basic php code.
I am using code like -

setcookie("bbstyleid", "333");

Is this correct? Or is the bbstyleid cookie part of an array of cookie values and I have to specify the array name or something?

Dismounted
07-29-2009, 10:26 AM
Remember that something has to be output to the user for any cookie changes to take effect. This is why a page must be displayed on logout, etc.

I'm not sure if you are doing this.

testbot
07-29-2009, 03:03 PM
i have no idea if this would work in template headerinclude

<if condition="$session[styleid] != 3">
$session[styleid] = 3
#redirect code here
</if>