View Full Version : How to restrict usergroups from using certain functionality?
Alfa1
01-20-2008, 09:41 PM
It is possible to restrict viewing of certain (template) functions to member groups of choice, by using this conditional:
<if condition="is_member_of($bbuserinfo,4,5,6,7)">[insert code that you want to restrict]</if>
4,5,6,7 are the user groups and can be replaced for any other user group.
This way you can for instance restrict all members, except those in usergroups 4,5,6 and 7 to see videos on profiles.
However, this way of restricting functions for visitors of the page is often confused with restricting functions for the member the function relates to. i.e. the member who's profile, post is concerned.
If you have a function on profiles or posts that you want to restrict to certain usergroups, then how do you handle that? For example: You want only users within usergroup 11and 12 to be able to show a video on their profile.
What conditional code can you use to accomplish this?
Should MEMBERINFO be modified for this or is there a more backend way of doing this?
Alfa1
07-31-2008, 08:15 PM
With a big thanks to Digital Jedi:
<if condition="in_array($post['usergroupid'], array(4,5,6,7))">[insert code that you want to restrict]</if>
Only 4,5,6 and 7 will be able to use the functionality.
Opserty
07-31-2008, 09:44 PM
the recommened way of doing things is using is_member_of() as it checks additional usergroups and also means that your code won't break if vBulletin change the usergroupid column name (obviously they really wouldn't but it is just an example of how it could break).
I didn't understand what half of your post said though. :confused:
$post is used in the postbit(_legacy) template so it won't have any effect in the MEMBERINFO template.
$userinfo or $prepared (3.6/3.7 respectively) are the variables in use in the MEMBERINFO template.
$bbuserinfo is the variable for the user that is currently browsing the page.
Alfa1
07-31-2008, 10:03 PM
Could you give me examples of how you would restrict a function on postbit and on MEMBERINFO? I am not certain of the syntax when using is_member_of().
Opserty
07-31-2008, 10:35 PM
You've given the correct usage in your first post. ;)
Alfa1
07-31-2008, 11:07 PM
Oh wow. I totally looked over that.
What are the variables for memberlist, groups, Blog and forum leaders?
RLShare
07-31-2008, 11:13 PM
the recommened way of doing things is using is_member_of() as it checks additional usergroups and also means that your code won't break if vBulletin change the usergroupid column name (obviously they really wouldn't but it is just an example of how it could break).
I didn't understand what half of your post said though. :confused:
$post is used in the postbit(_legacy) template so it won't have any effect in the MEMBERINFO template.
$userinfo or $prepared (3.6/3.7 respectively) are the variables in use in the MEMBERINFO template.
$bbuserinfo is the variable for the user that is currently browsing the page.
Doesn't ismemberof() add an extra query for evertime its executed on a page though?
Alfa1
07-31-2008, 11:21 PM
I dont think so. I checked before and after adding this.
RLShare
08-01-2008, 01:57 AM
Edit:
Oh no Im thinking of the can_moderate function.
Alfa1
08-06-2008, 02:38 PM
I tried to apply this code to newpost_usernamecode in order to add user group permissions to Anonymous posting (https://vborg.vbsupport.ru/showthread.php?t=177694)
I tried adding the red section:
--------------
<if condition="$show['anonymous'] AND is_member_of($post,4,5,6,7)"><div><input type="checkbox" id="cb_anonymous" class="bginput" name="anonymous" value="1" <if condition="$vbulletin->GPC['anonymous']">checked="checked"</if>/>$vbphrase[zointsanony_anonymous_post]</div></if>
--------------
Do you have any idea?
Lynne
08-06-2008, 02:43 PM
Who are you trying to check the permission for? $post may not be what you want to use there. Perhaps try $bbuserinfo (that checks the permission of the person viewing the thread/making the post).
Alfa1
08-06-2008, 03:03 PM
I am trying to check permission for the one posting the thread, which is also the one viewing the page, so that will work. Thank you.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.