Who's Online for Only Registered Members

Started by SwapsRulez, June 05, 2008, 01:20:26 AM

Previous topic - Next topic

SwapsRulez

Hi there, i'm using the SMF 2.0 Beta 3.1 With Overview theme here

http://www.project-bb.org/

i have commented the following code to not to show the online members to the guests.

/* echo '
<tr>
<td class="titlebg" colspan="2">', $txt['online_users'], '</td>
</tr><tr>
<td rowspan="2" class="windowbg" width="20" valign="middle" align="center">
', $context['show_who'] ? '<a href="' . $scripturl . '?action=who">' : '', '<img src="', $settings['images_url'], '/icons/online.gif" alt="', $txt['online_users'], '" />', $context['show_who'] ? '</a>' : '', '
</td>
<td class="windowbg2" width="100%">';

echo '
', $context['show_who'] ? '<a href="' . $scripturl . '?action=who">' : '', $context['num_guests'], ' ', $context['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ' . $context['num_users_online'], ' ', $context['num_users_online'] == 1 ? $txt['user'] : $txt['users'];

// Handle hidden users and buddies.
$bracketList = array();
if ($context['show_buddies'])
$bracketList[] = $context['num_buddies'] . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
if (!empty($context['num_spiders']))
$bracketList[] = $context['num_spiders'] . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
if (!empty($context['num_users_hidden']))
$bracketList[] = $context['num_users_hidden'] . ' ' . $txt['hidden'];

if (!empty($bracketList))
echo ' (' . implode(', ', $bracketList) . ')';

echo $context['show_who'] ? '</a>' : '', '
<div class="smalltext">';

// Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
if (!empty($context['users_online']))
{
echo '
', sprintf($txt['users_active'], $modSettings['lastActive']), ':<br />', implode(', ', $context['list_users_online']);

// Showing membergroups?
if (!empty($settings['show_group_key']) && !empty($context['membergroups']))
echo '
<br />[' . implode(']&nbsp;&nbsp;[', $context['membergroups']) . ']';
}

echo '
</div>
</td>
</tr>
<tr>
<td class="windowbg2" width="100%">
<span class="middletext">
', $txt['most_online_today'], ': <b>', $modSettings['mostOnlineToday'], '</b>.
', $txt['most_online_ever'], ': ', $modSettings['mostOnline'], ' (' , timeformat($modSettings['mostDate']), ')
</span>
</td>
</tr>';
*/


Now, i want to write such a condition that only registered members can see the online things means, i want this code to be executed if the member is registered member & not the guest.

So that registered members can see who is online, but guest much not see those details. Guest should see the scenario currently available in my site now.

Waiting for the sweet solution. Thanks in advance. :)
Project-BB.org : Educational Forum For Engineering, Diploma & Technical Students

The Engineering, Diploma & All technical students lounge for Free Projects, Seminars, Syllabus, Question Papers, College Assignments, Placement Papers, E-Books, Company Information & other technical stuffs.

spearfish

Try changing that to:


if (!$context['user']['is_guest']) {
echo '
            <tr>
               <td class="titlebg" colspan="2">', $txt['online_users'], '</td>
            </tr><tr>
               <td rowspan="2" class="windowbg" width="20" valign="middle" align="center">
                  ', $context['show_who'] ? '<a href="' . $scripturl . '?action=who">' : '', '<img src="', $settings['images_url'], '/icons/online.gif" alt="', $txt['online_users'], '" />', $context['show_who'] ? '</a>' : '', '
               </td>
               <td class="windowbg2" width="100%">';

   echo '
                  ', $context['show_who'] ? '<a href="' . $scripturl . '?action=who">' : '', $context['num_guests'], ' ', $context['num_guests'] == 1 ? $txt['guest'] : $txt['guests'], ', ' . $context['num_users_online'], ' ', $context['num_users_online'] == 1 ? $txt['user'] : $txt['users'];

   // Handle hidden users and buddies.
   $bracketList = array();
   if ($context['show_buddies'])
      $bracketList[] = $context['num_buddies'] . ' ' . ($context['num_buddies'] == 1 ? $txt['buddy'] : $txt['buddies']);
   if (!empty($context['num_spiders']))
      $bracketList[] = $context['num_spiders'] . ' ' . ($context['num_spiders'] == 1 ? $txt['spider'] : $txt['spiders']);
   if (!empty($context['num_users_hidden']))
      $bracketList[] = $context['num_users_hidden'] . ' ' . $txt['hidden'];

   if (!empty($bracketList))
      echo ' (' . implode(', ', $bracketList) . ')';

   echo $context['show_who'] ? '</a>' : '', '
                  <div class="smalltext">';

   // Assuming there ARE users online... each user in users_online has an id, username, name, group, href, and link.
   if (!empty($context['users_online']))
   {
      echo '
                     ', sprintf($txt['users_active'], $modSettings['lastActive']), ':<br />', implode(', ', $context['list_users_online']);

      // Showing membergroups?
      if (!empty($settings['show_group_key']) && !empty($context['membergroups']))
         echo '
                     <br />[' . implode(']&nbsp;&nbsp;[', $context['membergroups']) . ']';
   }

   echo '
                  </div>
               </td>
            </tr>
            <tr>
               <td class="windowbg2" width="100%">
                  <span class="middletext">
                     ', $txt['most_online_today'], ': <b>', $modSettings['mostOnlineToday'], '</b>.
                     ', $txt['most_online_ever'], ': ', $modSettings['mostOnline'], ' (' , timeformat($modSettings['mostDate']), ')
                  </span>
               </td>
            </tr>';
}

booher

try this around the code that shows the bottom:

if ($context['user']['is_logged']){
YOUR CODE
}

spearfish

booher.... which code specifically are you talking about?

You either need

if ($context['user']['is_logged']) {
// ALL OF THIS CODE
}


of what I showed.  He has it right now so that NOTHING shows.

SwapsRulez

Quote from: spearfish on June 05, 2008, 07:37:03 AM
booher.... which code specifically are you talking about?

You either need

if ($context['user']['is_logged']) {
// ALL OF THIS CODE
}


of what I showed.  He has it right now so that NOTHING shows.

Thanks your both... it worked like charm. :) Thanks sooo much. :D
Project-BB.org : Educational Forum For Engineering, Diploma & Technical Students

The Engineering, Diploma & All technical students lounge for Free Projects, Seminars, Syllabus, Question Papers, College Assignments, Placement Papers, E-Books, Company Information & other technical stuffs.

spearfish


Advertisement: