Member Totals in Administration Center >> Members

Started by GL700Wing, January 29, 2021, 10:08:05 PM

Previous topic - Next topic

GL700Wing

By default the 'View All Members' heading in the 'Administration Center » Members' section does not include the total number of members or, for the 'Search For Members'  heading, the total number of members found after a search.

The following code change will add the total number of members to the 'View All Members' heading:

In ./Sources/ManageMembers.php

Find:
$context['tabs'] = array(
'viewmembers' => array(
'label' => $txt['view_all_members'],


Replace With:
// Find out the total number of members ...
$request = $smcFunc['db_query']('', '
SELECT COUNT(*) AS member_count
FROM {db_prefix}members',
array()
);
list ($member_count) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);

$context['tabs'] = array(
'viewmembers' => array(
'label' => $txt['view_all_members'] . ' (' . $member_count . ')',





The following code change will add the total number of members to the 'Search For Members' heading for search results:

In ./Sources/ManageMembers.php
Find:
$context['sub_template'] = 'show_list';
$context['default_list'] = 'member_list';


Add Before:
// Added counter for search results.
if ($context['sub_action'] == 'query' && !empty($listOptions['get_count']['params']))
$context['tabs']['search']['label'] = $context['tabs']['search']['label'] . ' (' . call_user_func_array($listOptions['get_count']['function'], $listOptions['get_count']['params']) . ')';
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Steve

DO NOT pm me for support!


GL700Wing

#3
Quote from: Steve on January 30, 2021, 03:09:52 PM
Nice.
Quote from: Antechinus on January 30, 2021, 06:20:08 PM
Hey you're clever. :)
Thanks - I'm currently in the process of merging two forums for a business (one of which I've converted from BBPress) and I need to collect some information/stats about the usernames, display names and email address of the users (some of whom have accounts on both forums) and I didn't want to have to keep doing it via cPanel (although I do have to use cPanel to find all the BBPress member accounts that don't have a password* or valid email address!).

The other thing I did was a small code change to enable the usernames and display names fields to be searched separately.

In ./Sources/ManageMembers.php

Find:
'membername' => array(
'db_fields' => array('member_name', 'real_name'),
'type' => 'string'
),


Replace With:
'membername' => array(
'db_fields' => array('member_name'),
'type' => 'string'
),
'realname' => array(
'db_fields' => array('real_name'),
'type' => 'string'
),


In ./Themes/default/ManageMembers.template.php

Find:
<dt class="righttext">
<strong>', $txt['username'], ':</strong>
</dt>
<dd>
<input type="text" name="membername" value="" class="input_text" />
</dd>


Add After:
<dt class="righttext">
<strong>', $txt['display_name'], ':</strong>
</dt>
<dd>
<input type="text" name="realname" value="" class="input_text" />
</dd>





* The forum was converted to BBpress last year and all the member account passwords were lost in the process.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Advertisement: