News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Hiding group from memberlist?

Started by Goss, May 28, 2011, 08:28:47 AM

Previous topic - Next topic

Goss

I am using SMF 2.0 RC4 and am attempting to hide a particular group from the memberlist.  If a user has this group, "Inactive", as their primary group then their name will not be displayed on the memberlist.  However, I am not entirely sure how to go about doing this.  I know a little bit about queries, so went into memberlist.php and tried modifying one of the database queries in there.

// Select the members from the database.
$request = $smcFunc['db_query']('', '
SELECT mem.id_member
FROM {db_prefix}members AS mem' . ($_REQUEST['sort'] === 'is_online' ? '
LEFT JOIN {db_prefix}log_online AS lo ON (lo.id_member = mem.id_member)' : '') . ($_REQUEST['sort'] === 'id_group' ? '
LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN mem.id_group = {int:regular_id_group} THEN mem.id_post_group ELSE mem.id_group END)' : '') . '
LEFT JOIN {db_prefix}subaccounts AS sub ON (sub.id_member = mem.id_member)
WHERE mem.is_activated = {int:is_activated}' . (empty($where) ? '' : '
AND ' . $where) . '
AND sub.id_member IS NULL
AND mem.id_post_group != 22
ORDER BY {raw:sort}
LIMIT ' . $limit . ', ' . $modSettings['defaultMaxMembers'],
$query_parameters
);


I added in:
AND mem.id_post_group != 22

Unfortunately, that didn't seem to have any effect on the forum.  Am I doing something wrong or is there an alternative method I could be using?

Thank you!

anakmacan


Goss


Tyrsson

Question

How can a users primary group be a post count based group and them be inactive?
PM at your own risk, some I answer, if they are interesting, some I ignore.

live627


Goss

Ah, thank you live!  I hadn't realized I'd been looking at the wrong database field.  :)  I'll try that out!

JOSHSKORN

I just wanted to report a finding about this modification.

For some reason, I couldn't figure out how to not show admins and registered members.  Then, I decided to show only groups I specify.  I also found out that I couldn't just add 1 line with AND preceding the coding.  I had to use parentheses with OR.  Here's what I put in:

AND (mem.id_group = 9
OR mem.id_group = 10)


Insert that BEFORE this line:
ORDER BY {raw:sort}

Note: use '=' to show the groups, use '!=' to not show the groups.
To display more member groups on the members list, just add:
OR mem.id_group =
You must complete the above statement with the group number.

Advertisement: