News:

SMF 2.1.6 has been released! Take it for a spin! Read more.

Main Menu

Looking for $context['user'] information

Started by Norty, September 13, 2011, 04:10:17 AM

Previous topic - Next topic

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.

#1
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 :
    [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] =>
        )


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..


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
Quoteat that board or location
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.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Norty


Norty

I am using SMF 1.1.14

$context['user']['is_mod']  does not return true for Global Moderator.

Array
(
    [id] => 2
    [is_logged] => 1
    [is_guest] =>
    [is_admin] =>
    [is_mod] =>
.....

Kindred

global moderators are not "moderators" in the proper sense.

A moderator is a special "group" which is not assigned in the usual way. Moderators are only assigned in the BOARD settings (and on a per-board basis) are are only moderators in that board. Even admins should not flag the "is_mod" setting unless they are also marked as a moderator in that board.

You would have to check if the user's groups contain the global mod group ID.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Norty

Thanks Kindred.

I was looking for a shortcut  :-[

The security model works perfectly if an admin explicitly adds the fine-grained control to authorised groups.
One extra group (Global Mods) isn't going to be the end of the world.

iMav

I'm trying to use this context in my Display.template.php file.  Basically, I want to display "Thread Starter" verbage under the avatar of the user that has started the thread.  I am using the context as follows:


          if ($context['user']['started'])
                    echo '
                              <li class="threadstarter">
                                        <b>', $txt['thread_starter'], '</b>
                              </li>';


Unfortunately, it does not seem to identify any user...included the desired target of the thread starter.  If I negate the if, the desired text will show up for everybody...including the thread starter.

I'm at a loss...

iMav

aha!


$message['member']['is_topic_starter']


:)

Advertisement: