MyBB Community Forums

Full Version: MYBB custom SSI file fail?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
ok, so i can integrate mybb to my website easily but as soon as i put any of it into a function it doesn't work, i want to use it in a function so i can use it to make sort of like a smf ssi file, and organise it all better.

is there any way i can make this work?
I'm not sure what you mean, can you describe it a bit more?
normally the code would be

if ($mybb->user['uid']) {
        echo 'is logged';
} else {
        echo 'not logged';
}
which works fine but when i do this

function mybb() {
        if ($mybb->user['uid']) {
               echo 'not logged';
       } else {
               echo 'not logged';
        }
}
does not work, is there any way i can get it to work
You need to globalize the $mybb variable.

function mybb() {
        global $mybb;
        if ($mybb->user['uid']) {
               echo 'not logged';
       } else {
               echo 'not logged';
        }
} 
this works thanks