vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   is_member_of problem (https://vborg.vbsupport.ru/showthread.php?t=168304)

ragtek 01-20-2008 03:54 PM

is_member_of problem
 
hi
i don't understand why this https://vborg.vbsupport.ru/showthrea...17#post1425217 is a problem
the function is built this way:
PHP Code:

// #############################################################################
/**
* Works out if a user is a member of the specified usergroup(s)
*
* This function can be overloaded to test multiple usergroups: is_member_of($user, 1, 3, 4, 6...)
*
* @param    array        User info array - must contain userid, usergroupid and membergroupids fields
* @param    integer    Usergroup ID to test
* @param boolean    Pull result from cache
*
* @return    boolean
*/
function is_member_of(&$userinfo$usergroupid$cache true

so when i'm having:
PHP Code:

    if (is_member_of($vbulletin->userinfo$vbulletin->options['login_groups']))
    { 

and in login_groups stands: 3,4 then it should be
PHP Code:

    if (is_member_of($vbulletin->userinfo3,4))
    { 

but it seems at it isn't

does somebody know what i'm making false?

Opserty 01-20-2008 04:06 PM

Whats the value of $vbulletin->options['login_groups']?

(You'll need to explode() it if it is a character delimited list of group Ids.)

ragtek 01-20-2008 04:12 PM

The value is 2,3,4

It is a default fielt(textfield).
So i thouth it is saved as 2,3 into the db and then i can just insert the value into the function

nexialys 01-20-2008 04:20 PM

have to be
PHP Code:

if(is_member_of($vbulletin->userinfoexplode(','$vbulletin->options['login_groups']))) { 


ragtek 01-20-2008 04:25 PM

ok thx

Opserty 01-20-2008 04:26 PM

As nexialys has shown you need to explode it as 2,3,4 appears to PHP as string, like "2,3,4," so when you insert it into your function it would look like this: is_member_of($vbulletin->userinfo, "2,3,4") which as you have found won't work. ;)

ragtek 01-20-2008 04:32 PM

but then it returns an array.
and in the functioninformation there is no array required, so i thought it must be a list of numbers..

thx

nexialys 01-20-2008 05:12 PM

having read the next lines after the function is_member_of() { would have give you a hint, it verify if the $usergroupid is an array or not... ;)

ragtek 01-20-2008 05:27 PM

have you nothing to do with your baby, instead of saying/writing that i'm not reading the whole function?:P
*joke*;)

but yes, thats right
i thought the whole time that this is also so a function which accepts a string like the documentation sais:
Code:

* This function can be overloaded to test multiple usergroups: is_member_of($user, 1, 3, 4, 6...)

nexialys 01-20-2008 06:06 PM

hum the function documentation have a typo then... you can report it to the official site ;)

and yeah, i have a newborn, but i also have a wife and 3 other kids to take care of a 7 pounds baby.. lol... i take care of her when everybody is exhausted...

Adrian Schneider 01-20-2008 06:13 PM

overloaded does not mean accepts a string of ids, it means it will accept more than one integer.

func(1, 2, 3) is very different from func('1,2,3')

Kaelon 01-31-2008 09:58 PM

Just out of curiosity, where can the is_member_of function documentation be found? I had been winging it and guessing up until now :P.

Opserty 02-01-2008 01:45 PM

<a href="http://members.vbulletin.com/api/" target="_blank">http://members.vbulletin.com/api/</a>
vBulletin 3.6 Code Documentation

Cyberkef 02-29-2008 07:36 PM

Quote:

Originally Posted by nexialys (Post 1425246)
have to be
PHP Code:

if(is_member_of($vbulletin->userinfoexplode(','$vbulletin->options['login_groups']))) { 


Quote:

Originally Posted by Opserty (Post 1425252)
As nexialys has shown you need to explode it as 2,3,4 appears to PHP as string, like "2,3,4," so when you insert it into your function it would look like this: is_member_of($vbulletin->userinfo, "2,3,4") which as you have found won't work. ;)

God... I searched for days why it didn't worked, thanks! :D


All times are GMT. The time now is 09:08 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.01179 seconds
  • Memory Usage 1,752KB
  • 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
  • (5)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (14)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