vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   $ismod function - I want something similar? (https://vborg.vbsupport.ru/showthread.php?t=48776)

N9ne 02-10-2003 08:22 PM

$ismod function - I want something similar?
 
I have 5 separate usergroups for banned users, now what I want to do is instead of having to write out long if statements, just say $isbanned...how can I do this? I looked in functions.php but didn't find much to help me.

Xenon 02-11-2003 11:10 AM

create a function in functions.php
PHP Code:

function isbanned($userid=-1) {
      if (
$userid==-1) {
         
$usergroupid=$bbuserinfo[usergroupid];
} else {
    
$user=$DB_site->query_first("SELECT usergroupid FROM user where userid=$userid");
  
$usergroupid=$user[usergroupid];
}
return 
in_array($usergroupid, array(8,9,12,13));


replace the 8,9,12,13 with the usergroupids of your banned usergrous..

Dean C 02-11-2003 03:21 PM

Geez your too clever with that in_array function xenon ;)

- miSt

N9ne 02-11-2003 03:29 PM

And that will make $isbanned work globally right? It's just that I don't see any 'global' in there :p

Xenon 02-11-2003 04:03 PM

it's a function, so it would always work globaly.

it's like ismoderator.

so your $ in front is incorrect!

also, please change your sig to fit with the rules!

N9ne 02-11-2003 04:30 PM

So if it's a function, I can't use it as a variable? I'd have to use isbanned() wouldn't I? Is there a way I could use it like you can use $ismod...I want to use $isbanned instead.





edited my sig, completely forgot about the rules :o.

Xenon 02-11-2003 04:39 PM

thx

i don't see why you want to use it as a variable, it has no sense normally...
if use use a var or the function it's equal..

but you can do this:
Code:

$isbanned=isbanned();
that's the way it's done with $ismod, it's just because of a caching feature...

N9ne 02-11-2003 05:13 PM

In an if statement, which of the following can I do then?

PHP Code:

if ($isbanned=isbanned();) {
echo(
"blah");
}

if(
$isbanned) {
echo(
"blah");
}

if(
isbanned()) {
echo(
"blah");



N9ne 02-11-2003 05:14 PM

Grr, it keeps parsing a smilie, the first one eshould be:

if ($isbanned=isbanned()__)__{
echo("Blah");
}

Just remove the underscores.

Xenon 02-11-2003 05:21 PM

use this:
PHP Code:

if(isbanned()) {
echo(
"blah");




All times are GMT. The time now is 08:31 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.01066 seconds
  • Memory Usage 1,733KB
  • 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
  • (3)bbcode_php_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