TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

March 29, 2024, 04:58:00 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,105
  • Total Topics: 21,213
  • Online today: 304
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 301
  • Total: 301

Top Posters

Started by darkangel, February 07, 2014, 09:09:10 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

darkangel

You all gave me this code eons ago...we luvs it a lot too but is there anyway to have it ignore---not show the admins in the list?



global $smcFunc, $scripturl, $modSettings, $context;

// Number of top posters displayed
$topPoster = 45;

// Find the latest poster.
$request = $smcFunc['db_query']('', '
SELECT mem.id_member, mem.show_online, mem.real_name, mem.posts, a.id_attach, a.attachment_type, a.filename
FROM ({db_prefix}members as mem)
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member)
WHERE ' .($context['user']['is_admin'] ? '1' : 'show_online = 1') . '
ORDER BY posts DESC
LIMIT {int:limit}',
array('limit' => $topPoster)
);

$users = array();

while ($row = $smcFunc['db_fetch_assoc']($request))
{
$users[] = array(
'id' => $row['id_member'],
'name' => $row['real_name'],
'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',
'posts' => $row['posts'],
'show' => $row['show_online'],

);
}

$smcFunc['db_free_result']($request);

// Output our array of users with avatar, posts, and name
echo '
<table cellpadding="0" cellspacing="10">';

foreach ($users as $user)
{
echo '
<tr>

<td><h5 style="margin: 4px,0,0,4px;">'.$user['link'].'</h5></td><td><h5 style="margin: 4px,0,0,4px;">'. $user['posts'] .'</h5></td>
</tr>';
}

echo '
</table>';


Fantasies Realm  | Fantasy Attic

SMF 2.0.15 | TP 1.2 | many mod addons | variety of themes

IchBin

You can add a check in like this right after the foreach loop.

foreach ($users as $user)
{
    if ($user['id'] = 1)
        continiue;

   
If you need to check for multiple admins you can use an array.

foreach ($users as $user)
{
            $admins = array(1,3,4);
    if (in_array($user['id'], $admins))
        continiue;


darkangel

so the 1, 3, 4 should it be the actual admin id # --- like our admins are 1,2,3,4

with a token one that never gets used anymo...LOL
Fantasies Realm  | Fantasy Attic

SMF 2.0.15 | TP 1.2 | many mod addons | variety of themes

darkangel

 :(

Admins still show in list, this is how I did it. Did I do it right?






foreach ($users as $user)
{
$admins = array(1,2,3,4);
    if (in_array($user['id'], $admins))
       
continue;
echo'
Fantasies Realm  | Fantasy Attic

SMF 2.0.15 | TP 1.2 | many mod addons | variety of themes

IchBin

Assuming that 1,2,3,4 are the ID numbers for your admin accounts?

darkangel

yes when I set up the site I set them up in order as well
Fantasies Realm  | Fantasy Attic

SMF 2.0.15 | TP 1.2 | many mod addons | variety of themes

IchBin

Well I just tried this code and it worked fine:


global $smcFunc, $scripturl, $modSettings, $context;

// Number of top posters displayed
$topPoster = 45;

// Find the latest poster.
$request = $smcFunc['db_query']('', '
SELECT mem.id_member, mem.show_online, mem.real_name, mem.posts, a.id_attach, a.attachment_type, a.filename
FROM ({db_prefix}members as mem)
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member)
WHERE ' .($context['user']['is_admin'] ? '1' : 'show_online = 1') . '
ORDER BY posts DESC
LIMIT {int:limit}',
array('limit' => $topPoster)
);

$users = array();

while ($row = $smcFunc['db_fetch_assoc']($request))
{
$users[] = array(
'id' => $row['id_member'],
'name' => $row['real_name'],
'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',
'posts' => $row['posts'],
'show' => $row['show_online'],

);
}

$smcFunc['db_free_result']($request);

// Output our array of users with avatar, posts, and name
echo '
<table cellpadding="0" cellspacing="10">';

foreach ($users as $user)
{
$admins = array(1,2);
if (in_array($user['id'], $admins))
continue;
echo '
<tr>

<td><h5 style="margin: 4px,0,0,4px;">'.$user['link'].'</h5></td><td><h5 style="margin: 4px,0,0,4px;">'. $user['posts'] .'</h5></td>
</tr>';
}

echo '
</table>';

darkangel

As with everything else I hae done today---including a tossing a folder containing info about our contest for Dec 2013 and Jan -now of winner info and emptying trash bin--what will go right mebbe?

I copy pasted your code you tried....and went to my forum/deleted all from box/saved
then entered your code adding the other 2 admins and they are now gone from list. this sure beats going into the accounts and resetting us to 0, since it is to motivate the members to write more posts...LOL

Thanks for your patience with this dolt. It now works. O0
Fantasies Realm  | Fantasy Attic

SMF 2.0.15 | TP 1.2 | many mod addons | variety of themes