1 (edited by Koos 2007-12-21 13:47)

Topic: $pun_user['g_id'] variable empty with guest messages

Why does the $pun_user['g_id'] variable return empty when a message is displayed for a guest?

For example when using:

message($lang_uploadimg['No permission']);

$pun_user['g_id'] is empty when you are a guest, instead of 3.

2

Re: $pun_user['g_id'] variable empty with guest messages

I would assume that $pun_user is not a global in the message function, at first guess.

3

Re: $pun_user['g_id'] variable empty with guest messages

Just checked. It's not.

function message($message, $no_back_link = false)
{
        global $db, $lang_common, $pun_config, $pun_start, $tpl_main;

Just add $pun_user to that global line to make it available.

4 (edited by Koos 2007-12-21 13:58)

Re: $pun_user['g_id'] variable empty with guest messages

Thanks, that did the trick. Is there a reason why $pun_user was not made global in the message function in the first place?

Re: $pun_user['g_id'] variable empty with guest messages

Because it's not used? wink

6 (edited by Koos 2007-12-22 17:31)

Re: $pun_user['g_id'] variable empty with guest messages

Smartys wrote:

Because it's not used? wink

I think it would have been nice to have it there - just for completeness. Why return the correct $pun_user['g_id'] for messages when your are logged in - but have it empty instead of 3 when you're a guest? Some modifications I have done looks at $pun_user['g_id'] when messages are displayed.

Re: $pun_user['g_id'] variable empty with guest messages

I don't know what you mean. The issue isn't setting the value, it's making $pun_user global, which it only is when header.php hasn't been called before the message function (since we need to know the style to use, for example).