Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

August 12, 2022, 05:51:17 AM

Login with username, password and session length
Members
  • Total Members: 3842
  • Latest: Kokoro
Stats
  • Total Posts: 193479
  • Total Topics: 21088
  • Online today: 50
  • Online ever: 1035
  • (November 26, 2020, 04:45:12 AM)
Users Online
Users: 0
Guests: 52
Total: 52

Author Topic: Top Posters  (Read 8071 times)

0 Members and 1 Guest are viewing this topic.

Offline darkangel

  • Beta Tester
  • *
  • Posts: 371
Top Posters
« on: February 07, 2014, 02:09:10 AM »
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?

Code: [Select]

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

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: Top Posters
« Reply #1 on: February 08, 2014, 04:09:02 PM »
You can add a check in like this right after the foreach loop.

Code: [Select]
foreach ($users as $user)
{
    if ($user['id'] = 1)
        continiue;
   
If you need to check for multiple admins you can use an array.

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

Offline darkangel

  • Beta Tester
  • *
  • Posts: 371
Re: Top Posters
« Reply #2 on: February 08, 2014, 04:47:28 PM »
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

Offline darkangel

  • Beta Tester
  • *
  • Posts: 371
Re: Top Posters
« Reply #3 on: February 08, 2014, 07:47:44 PM »
 :(

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

Code: [Select]




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

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: Top Posters
« Reply #4 on: February 08, 2014, 08:40:14 PM »
Assuming that 1,2,3,4 are the ID numbers for your admin accounts?

Offline darkangel

  • Beta Tester
  • *
  • Posts: 371
Re: Top Posters
« Reply #5 on: February 08, 2014, 09:01:30 PM »
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

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: Top Posters
« Reply #6 on: February 08, 2014, 09:10:48 PM »
Well I just tried this code and it worked fine:

Code: [Select]
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>';

Offline darkangel

  • Beta Tester
  • *
  • Posts: 371
Re: Top Posters
« Reply #7 on: February 08, 2014, 09:58:12 PM »
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