vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Check if User is in Usergroup (PHP) (https://vborg.vbsupport.ru/showthread.php?t=229588)

chsmith700 12-05-2009 08:56 PM

Check if User is in Usergroup (PHP)
 
Hello,

I am writing a custom script and having some issues verifying if a user is in a usergroup, not in the template file but in the PHP. I tried this but it doesnt seem to be working correctly, What am I doing wrong?

Code:

if ($userinfo['usergroupid'] == 6) {
 somestuff
} else {
 someotherstuff
}

I tried just doing an echo '<vb:if condition=\"is_member_of($vbulletin->userinfo, 6)\">' statement but when I do that is displays in the source an array.

ForumsMods 12-05-2009 09:29 PM

PHP Code:

if (is_member_of($vbulletin->userinfo6)) {
    
somestuff
} else {
    
someotherstuff



chsmith700 12-06-2009 07:13 PM

Awesome, thanks alot!

Weetabix 12-26-2009 11:48 AM

Could this be used to enable style selection for certain (sub) usergroups only?

TransAmDan 08-20-2015 05:18 PM

I wonder if this should work in the forum Blocks area?
I have the following:-

if (is_member_of($vbulletin->userinfo, 6)) {
$my_output = '';
} else {
$my_output = ' google adsence code......';
}
return $my_output;

However no matter what usergroup I choose the advertising is always displayed. 6 is Admin usergroup and I am admin. I choose usergroup 1 for not logged in, and try that without being logged in, but it still displays the advertising.
I know its not a cached issue, as I just popped in some test text, and that was displayed.

MarkFL 08-20-2015 05:24 PM

Try adding the following to the top of your Content (PHP code)

PHP Code:

global $vbulletin



All times are GMT. The time now is 06:39 AM.

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.01526 seconds
  • Memory Usage 1,714KB
  • 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_code_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete