vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   How to restrict usergroups from using certain functionality? (https://vborg.vbsupport.ru/showthread.php?t=168333)

Alfa1 01-20-2008 09:41 PM

How to restrict usergroups from using certain functionality?
 
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

Quote:

Originally Posted by Opserty (Post 1588708)
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
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?


All times are GMT. The time now is 10:29 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00966 seconds
  • Memory Usage 1,737KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete