On a site I took over from another developer, I need to output a list of members from multiple member groups (Staff, Editors, Super Admins) but only one Super Admin member needs to show in it.

The current implementation uses an obscure plugin — it might be a custom add-on as I can't find it via Google — to list members in the Staff and Editors groups. The need to show a single member of the Super Admin member is a new requirement.

If possible, I would like to avoid using an exclude by member_id approach — that is filtering by a list of member_ids that I do not want to show. Instead, I would like to include by member_id, so only that one specified member is listed. So more {if member_id == ""} and not {if member_id != "}, but with the need to show all members in the other two groups.

Going that route, as new Super Admins are added (which is very infrequently) I won't have to revisit the project to add yet another member_id exclusion.

but an include by member_id, so only a specific Super Admin will show in the list. That way, as new Super Admins are added (which is very infrequently) I won't have to revisit the project to add another exclusion.

Any thoughts?

  • Can you clarify your question? Your first sentence doesn't entirely make sense. Commented Nov 21, 2012 at 0:37
  • You're right, it was a bit unclear. Rewrote the bulk of my question so it should be clearer now. Commented Nov 21, 2012 at 1:25

1 Answer 1


There are probably multiple ways to accomplish this but the Query module has really become my go-to when there are specialized requirements for the data I want to display, or when there aren't obvious ways to do something with regular EE tags.

Here is an example of what I think you are asking for. Show all the members for a couple member groups (add more if needed) and also for a single suepradmin, selecting that member by id.

{exp:query sql=
    "SELECT screen_name, group_title
    FROM exp_members
    JOIN exp_member_groups ON exp_member_groups.group_id = exp_members.group_id
    WHERE exp_members.group_id = 6 OR exp_members.group_id = 7 OR exp_members.member_id = 1"
    <li>{screen_name}, {group_title}</li>

This would output something like

<li>Willie Nelson, Super Admins</li>
<li>Johnny Cash, Staff</li>
<li>Merle Haggard, Staff</li>
<li>Doc Watson, Editors</li>
<li>Ralph Stanley, Editors</li>


It's been mentioned in the comments below, and in this answer, that the Query module does not escape data so is unsafe for queries containing user input such as segment data. One of the suggested alternatives is to use the Active Record plugin instead, which does escape data.

With that in mind, and even though there is no user input in this particular query, here is the same query using the Active Record plugin instead of the Query module:

    select="screen_name, group_title"
    on="exp_member_groups.group_id = exp_members.group_id"
    <li>{screen_name}, {group_title}</li>
  • 1
    This sounds like it's nearly exactly what the custom plugin is doing. Overall I recommend using custom plugins instead of the query plugin - it is more maintainable and safer to do so. Commented Nov 21, 2012 at 2:40
  • @IsaacRaway I see the maintainability aspect. Curious, though, what's the safety aspect?
    – Alex Kendrick
    Commented Nov 21, 2012 at 3:02
  • @AlexKendrick Ah, that looks like it should work perfectly, you even have the group_ids correct. :-) Appreciate the help! Commented Nov 21, 2012 at 5:26
  • @IsaacRaway Not quite. The list was showing all of the Staff and Editors only. The new requirement to include a specific Super Admin is why I looking for a better solution. Like Alex, I'm also curious about the safety aspect of a plugin vs a query. Commented Nov 21, 2012 at 5:29
  • 1
    The safety aspect Isaac alludes to is that if you're taking user input (like via segment data), the query plugin will NOT auto-escape that. If you don't feel like writing a custom plugin, you can get around the safety problem by using Rob Sanchez' Active Record plugin, which does escape data.
    – adrienne
    Commented Nov 21, 2012 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.