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 ;)
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.
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?
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>
If you are in a source file $user_info is available too.
Thanks guys. I will test this tonight.
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] =>
.....
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.
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.
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...
aha!
$message['member']['is_topic_starter']
:)