View Full Version : Force Style to Certain Usergroup(s) and/or User(s)
Hack Support
This hack is now discontinued - this means that while it will remain available for download and use, there will be no further updates, nor will support be provided as the thread is no longer monitored.
Please click Mark as Installed if you are using this hack.
vBulletin Version Compatibility
This hack has be tested with v3.5.8. This has not been tested with earlier versions, but should work.
What Does This Hack Do?
This hack allows you to force a style to certain usergroup(s), secondary usergroup(s), and/or certain user(s).
Background
This is inspired by the hack - Restrict Style to Usergroup(s) by Andreas.
I asked about a mod to restrict styles to certain usergroups and ended up using Andreas's hack, but did not do the job exactly as I need it, see scenario below to see why did not.
Scenario
The setup on my forums is that I use the default style as the parent to all my other styles which makes modifying the templates easy for me, I wanted to use a child style as the standard style for visitors and members, but not have them have a choice of the default template at all, but as soon as you logged out you were presented with the default template that you did not want guests to see.
Solution
I created this hack to rectify that and it works in harmony with Andreas's hack.
Installation Instructions
Instructions and upgrade instructions are in the attachment.
Note: No screenshots are needed, so are not provided.
Version History
v1.02 - Tuesday 28th February 2006
-- Final release
-- Fixed: Plugin typo
v1.01 - Thursday 23rd February 2006
-- Added: Secondary Usergroups permissions
v1.00 - Thursday 23rd February 2006
-- Initial Release
Show Your Appreciation
Although not required, if you have enjoyed the benefits of this hack, and would like show your appreciation for my efforts, then please feel free to click on the Support Developer link and donate any amount you feel is appropriate.
RoryF
02-22-2006, 02:58 PM
Exactly what i need. Thankyou for making this hack :D. Well done :).
Just to clarify, you said that this works just fine in conjunction with Andreas' Restrict Style to Usergroup(s) (https://vborg.vbsupport.ru/showthread.php?t=95910) hack without any conflict?
Also: Does this work with secondary usergroups as well?
Just to clarify, you said that this works just fine in conjunction with Andreas' Restrict Style to Usergroup(s) (https://vborg.vbsupport.ru/showthread.php?t=95910) hack without any conflict?
Also: Does this work with secondary usergroups as well?
Yes, no conflicts at all.
Not in it's current state, but I will put that in, in a bit for you :)
Now Zip file has now been updated to deal with Secondary Usergroups.
christianjunk
02-27-2006, 11:12 AM
Hi!
There's an error in your code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<plugins>
<plugin active="1" product="vbulletin">
<title>Force Styles for Selected Usergroups</title>
<hookname>style_fetch</hookname>
<phpcode><![CDATA[if (in_array($vbulletin->userinfo['usergroupid'], array(a,b,c)) || (in_array($vbulletin->userinfo['membergroupids'], array(d,e,f)))
{
$styleid = 8;
}]]></phpcode>
</plugin>
</plugins>
You forgot a closing ")" in the if-statement (before "{") ...
Regards,
Christian
Hi!
There's an error in your code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<plugins>
<plugin active="1" product="vbulletin">
<title>Force Styles for Selected Usergroups</title>
<hookname>style_fetch</hookname>
<phpcode><![CDATA[if (in_array($vbulletin->userinfo['usergroupid'], array(a,b,c)) || (in_array($vbulletin->userinfo['membergroupids'], array(d,e,f)))
{
$styleid = 8;
}]]></phpcode>
</plugin>
</plugins>
You forgot a closing ")" in the if-statement (before "{") ...
Regards,
Christian
Thanks for noticing that typo :) updated the zip file.
ToyotaDiesel
04-19-2006, 01:09 PM
.......
ToyotaDiesel
04-19-2006, 05:20 PM
I have secondary usergroups that i can't get it to work with.
for instance:
Works with Usergroup 12 and 2, not with 17, 24, and 29.
Is there a cap on usergroup id#s?
Thanks
ToyotaDiesel
04-19-2006, 05:52 PM
I cannot get it to work with a usergroupid higher than 12. (my usergroups jump from 12 to 17 btw)
Works on 12. down.
Doesnt work on 17, up.
(I'm trying secondary usergroups btw)
ToyotaDiesel
04-20-2006, 12:46 PM
Anyone? I'm getting by using the user level version, but the usergroup script would make it alot easier to see whos in the group and whos not.
Post the Style ID you want to restrict to certain groups, and the primary and secondary membergroups you want to limit. And I will PM you the script with the appropriate info already in it.
So do it as:
Style ID:
Primary Groups:
Secondary Groups:
ToyotaDiesel
04-20-2006, 05:04 PM
thanks. This is what I was using
if (in_array($vbulletin->userinfo['usergroupid'], array()) || (in_array($vbulletin->userinfo['membergroupids'], array(29))))
{
$styleid = 9;
}
Style ID: 9
Primary Groups: none
Secondary Groups: 29
Try this instead:
if (in_array($vbulletin->userinfo['membergroupids'], array(29)))
{
$styleid = 9;
}
Tell me if that works.
ToyotaDiesel
04-21-2006, 01:17 PM
Thanks. I get this at the top of the page with that line
Parse error: parse error, unexpected '{' in /home/public_html/forums/global.php(233) : eval()'d code on line 2
ToyotaDiesel
04-21-2006, 01:24 PM
I added a close parenthesis, and it fixed the parse error listed above, but otherwise the code is working the same.
It works fine with all secondary usergroups with an id# of less than 12.
ToyotaDiesel
04-21-2006, 01:33 PM
Usergroup ids 13-16 were deleted. Would this lack of ID #s cause a problem? Seems like thats where the problem starts. Nothing greater than that block of deleted ids will work.
You may need to rebuild your Styles to get this to work.
Maintenance -> Update Counters - > Rebuild Styles.
Select Yes for both Check For Styles With No Parent and Renumber all templates from 1..
If that does not work, then I do not have a clue, as it should work as advertised.
ToyotaDiesel, I had a thought, if you are using this mod with Restrict Style to Usergroup(s) by Andreas, then make sure the style you are using for this secondary member group has the correct permissions for the group to be able to use it.
Warlock40
05-07-2006, 04:31 AM
Usergroup ids 13-16 were deleted. Would this lack of ID #s cause a problem? Seems like thats where the problem starts. Nothing greater than that block of deleted ids will work.
Initially I had the same problem. I could not get a specific style to work.
My problem was that I had the style set as "not user selectable"
so members could not pick it.
So to get have my cake and eat it to. I uploaded andreas hack https://vborg.vbsupport.ru/showthread.php?t=95910
and then allowed the style to be select by a specific user group, and then used this hack to set it as a default for that user group.
I also had this set as a default for a cmps page different from my home but in order to keep that I then just created a child and set that to non user selectable and pointed it to my cmps page so that it could get style (as the other was restricted.
So now members who are new or visit the specific page or forum area or are part of a specified usergroup can enjoy this style.
Thanks for the hack.
Oh and if there is an easier way to make this so it can be used by non user selectable styles I'll be happy to change it all back..it will save me some keystrokes down the road.
If it can not be selected by the user, it can not be used by that user unfortunately and my mod will not work, it is what permissions is all about.
My mod is used in conjunction with Andrea's one (advanced permissions for each style) to force a particular style on a user or a group of users (but the user or group have to have permissions to select/see the style being forced on them).
beano33
01-30-2007, 07:46 PM
I force a lite style during periods of high server loads. Does anyone know how to add a trigger to this plugin so it would only go active at a defined server load? I suspect it might involve adding another plugin to the global.php hook location. Thanks!
The Equivocate
03-14-2007, 05:04 AM
Hey, I'm using this hack to implement a "multi-site" shared forum. Because the sites will be referring hits based on style id (I.E. the affiliate has skin id #2 branded with their logos/ads, so they'd use mysite.com/index.php?styleid=2), Unregistered Users need to have all the skins available to them, and their skin defined via the styleid in the URL.
What change would I have to make? I know absolutely nothing about PHP, but here's the change I tried to make to allow Unregs (usergroup ID #1) to view both skin styleid #1 AND #2 (but let's pretend there's going to be about 6 more). It's giving me a parse error and only showing skin #2.:
if (in_array($vbulletin->userinfo['usergroupid'], array(1)) || (in_array($vbulletin->userinfo['membergroupids'], array(1))))
{
$styleid = 1,2;
}
Hey, I'm using this hack to implement a "multi-site" shared forum. Because the sites will be referring hits based on style id (I.E. the affiliate has skin id #2 branded with their logos/ads, so they'd use mysite.com/index.php?styleid=2), Unregistered Users need to have all the skins available to them, and their skin defined via the styleid in the URL.
What change would I have to make? I know absolutely nothing about PHP, but here's the change I tried to make to allow Unregs (usergroup ID #1) to view both skin styleid #1 AND #2 (but let's pretend there's going to be about 6 more). It's giving me a parse error and only showing skin #2.:
if (in_array($vbulletin->userinfo['usergroupid'], array(1)) || (in_array($vbulletin->userinfo['membergroupids'], array(1))))
{
$styleid = 1,2;
}
This is only to force a 1 style on member group(s).
You can not have multiple style ids as you have them, this is what is causing the parse error:
$styleid = 1,2;
If you want to have guests use all styles then do not use this hack. Only use this hack for the member groups you want to restrict to a particular style.
If you want to restrict say 2 different member groups to one style and say 1 different member group to another style then here is an example of how to do it.
if (in_array($vbulletin->userinfo['usergroupid'], array(2,3)))
{
$styleid = 1;
}
if (in_array($vbulletin->userinfo['usergroupid'], array(4)))
{
$styleid = 2;
}
Also please click INSTALL, as you said you are using this hack.
lostgirl815
03-23-2007, 05:16 AM
Is there any chance that I can use this with 3.6.4?
Is there any chance that I can use this with 3.6.4?
It should work with v3.6.x :)
lostgirl815
03-24-2007, 08:37 PM
Great! Thanks for your answer! :)
--------------
Worked like a charm in the test run - thanks so much for this one!
Great! Thanks for your answer! :)
--------------
Worked like a charm in the test run - thanks so much for this one!
You are most welcome :)
The official v3.6.x version of this modification is now available from here.
Thanks for your patience, and hope all of you users with v3.6.x will enjoy this ported mod :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.