help with ssi.php on my wordpress blog

Started by kL, March 11, 2007, 07:42:58 PM

Previous topic - Next topic

kL

i have required ssi.php on my main site - http://www.kanyetalk.com/
now the only problem is, i cant use ssi.php to check if the user is a guest or logged. the same exact code works in the actual forum, but not on the main site. $context['user']['is_logged'] returns nothing.
it should show when the user is logged in, yet it doesnt. but it does in the forum itself.
there isnt anything wrong with my code, so it must be something wrong with ssi.php.
other things relating to ssi.php work fine, as you can see.
so what is the problem!!?


codenaught

Can you show us how you are using it? If you are using the code inside a function you need to make sure that you global $context like: global $context;  
Dev Consultant
Former SMF Doc Coordinator

kL

i have
require("/home/.mogadishu/ktalk/kanyetalk.com/talk/SSI.php"); at the top of the wordpress index.php file (not the theme file), so it is before everything

and in the theme dir in header.php:


<?php if ($context['user']['is_logged']) {$menu2='/images/menu2_logged.png';} else {$menu2='/images/menu2_guest.png';} 
if (
$context['user']['unread_messages'] > )  {$menu2='/images/menu2_logged_new.png';} 
?>

<img src="<?php bloginfo('template_directory'); echo $menu2?>" border="0" usemap="#menu2x" />


the same code works fine in smf itself.


kL

#5
ughhh

kL


codenaught

Is that code in a function? If so, you want to make sure you global $context like this:

<?php

function some_function()
{
        global 
$context;

        <
other php code>
}

?>
Dev Consultant
Former SMF Doc Coordinator

spl1nter

I'm having this exact same problem. My code is not inside any function.

spottedhog

sometimes you may need to disable local cookies and enable subdomain cookies

spl1nter

I did as you suggested and unfortunately that didn't work. I can get SSI.php to work on every page on my site that I've coded myself, but when I try to use it within wordpress I get nothing. I'm just try to use $context['user']. I tried print_r($context['user']) but it doesn't display anything, the variable just doesn't exist.

I tried editing SSI.php to echo something just to check it was being called properly and it is. I've tried placing the require() in the template header, wp-config.php and wp-settings.php to no success.

spottedhog

Try placing this above where you are using $context:

global $context;

Advertisement: