View Full Version : is_member_of problem
ragtek
01-20-2008, 03:54 PM
hi
i don't understand why this https://vborg.vbsupport.ru/showthread.php?p=1425217#post1425217 is a problem
the function is built this way:
// ################################################## ###########################
/**
* 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:
if (is_member_of($vbulletin->userinfo, $vbulletin->options['login_groups']))
{
and in login_groups stands: 3,4 then it should be
if (is_member_of($vbulletin->userinfo, 3,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 if(is_member_of($vbulletin->userinfo, explode(',', $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:
* 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
have to be if(is_member_of($vbulletin->userinfo, explode(',', $vbulletin->options['login_groups']))) {
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
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.