Customizing SMF > SMF Coding Discussion

Looking for $context['user'] information

(1/3) > >>

Norty:
I am looking for a listing of the $context['user'][xxxxx] variables.

I have used $context['user']['is_guest'] and $context['user']['is_admin'].

I am now looking for something like $context['user']['is_globalmoderator'].
I am also keen to see what other variables would be of use.  I may be able to do some refactoring of my bloated noob code ;)

Ricky.:
There is :
$context['user']['is_mod']
If its true then he is mod at that board or location !'

I hope that helps..

Here is $context['user'] output :

--- Code: ---    [user] => Array
        (
            [id] => 0
            [is_logged] =>
            [is_guest] => 1
            [is_admin] =>
            [is_mod] =>
            [username] =>
            [language] => english
            [email] =>
            [name] =>
            [smiley_set] => default
            [started] =>
            [messages] => 0
            [unread_messages] => 0
            [avatar] => Array
                (
                )

            [total_time_logged_in] => Array
                (
                    [days] => 0
                    [hours] => 0
                    [minutes] => 0
                )

            [popup_messages] =>
        )

--- End code ---

Above is from test board as guest.

Norty:

--- Quote from: Ricky. on September 13, 2011, 04:21:42 AM ---There is :
$context['user']['is_mod']
If its true then he is mod at that board or location !'

I hope that helps..


--- End quote ---

Thanks Ricky.  I will try this tonight.
One question:  The user will not be on any specific board, but rather in my custom page.  I am looking specifically for Global Moderators.
Could I safely assume that
--- Quote ---at that board or location
--- End quote ---
means that a global moderator will always return true?

Ricky.:
Yes it should technically, best way is to simply add following in your test board :
echo '<pre'>;print_r($context['user');echo '</pre>';

Now you can see variable behavour yourself. Best place would be adding it in index.template.php before </body>

emanuele:
If you are in a source file $user_info is available too.

Navigation

[0] Message Index

[#] Next page

Go to full version