PDA

View Full Version : $variable inside vbulletin conditions


Mickie D
06-10-2015, 10:35 AM
Hi all,

I have a fairly simple question, I have tried numerous ways of doing this with out much luck

Writing a basic modification for my site and it uses vbulletin usergroup permissions to access it.

I wanted to do something like this but it does not work



$webspace_canuse_global = '6, 7, 18';

if (!is_member_of($vbulletin->userinfo, $webspace_canuse_global)) {
print_no_permission();
}else{

// do the script



It works if I put the 6,7,18 in place of the variable, what am i doing wrong...


I am going to make a backend that uses SQL in the future so the variable will end up being a call to the database...

Black Snow
06-10-2015, 10:53 AM
Have you tried it with double quotes instead of singles?
$webspace_canuse_global = "6, 7, 18";

Mickie D
06-10-2015, 10:56 AM
Have you tried it with double quotes instead of singles?
$webspace_canuse_global = "6, 7, 18";

yep tried that, I also tried putting the variable in "" inside the array

Cheers
Mick

Black Snow
06-10-2015, 11:02 AM
If this doesn't work:
$webspace_canuse_global = '6,7,18';

if (!is_member_of($vbulletin->userinfo, $webspace_canuse_global)) {
print_no_permission();
}else{

// do the script

Try this:
$webspace_canuse_global = '6,7,18';

if (!is_member_of($vbulletin->userinfo, explode(',', $webspace_canuse_global))) {
print_no_permission();
}else{

// do the script

--------------- Added 1433941567 at 1433941567 ---------------

Oh, and keep the numbers seperated by commas only. Not commas and spaces.

Mickie D
06-10-2015, 11:51 AM
explode worked (thank you), I had a feeling it might need explode, just thought there would be a more kinder way to do it.

Regards
Mick