I'm trying to figure out how to have a page that lists all members with basic fields like email, screen_name and then all the other custom member fields I created.
4 Answers
Please see this thread: Display members in group in template
You will probably need to use an extension or plugin to do this easily. Something like solspace User or another plugin that will allow you to output your list directly.
Another option is accessing the member data via query but you will need to do some work to the query to get it to show the custom profile data. The standard query for members is:
{exp:query sql="SELECT * FROM exp_members"}
and if you need to group them by member group:
{exp:query sql="SELECT * FROM exp_members WHERE group_id='2'"}
In this way you could get your member IDs and send them to an embedded template. Please note that it is probably more efficient to use a custom query instead of an embed.
{exp:query sql="SELECT member_id FROM exp_members"}
{member_id}
{embed="member-info-embed-template-path" member_id="{member_id}"}
{/exp:query}
then your embed template can output standard custom profile tags
{exp:member:custom_profile_data member_id="{embed:member_id}"}
<div>{your_custom_profile_tag}</div>
{/exp:member:custom_profile_data}
For query speed with many members you will probably want to do away with the embed method and directly output all your member data via a custom query. You will need to do a JOIN for exp_members and exp_member_data based on the member id. I think the following will get you there.
{exp:query sql="SELECT * FROM exp_members INNER JOIN exp_member_data
ON exp_members.member_id = exp_member_data.member_id
GROUP BY exp_members.member_id
ORDER BY exp_members.member_id ASC
LIMIT 10"}
{member_id} {screen_name} {m_field_id_2}<br />
{/exp:query}
you can adjust the above query as needed to limit your results by adding WHERE and AND clauses like WHERE group_id='4' AND m_field_id_2='whatever'
just keep in mind that you'll need to use m_field_id_NUMBER instead of the EE field name if you are using the above query as is. Also, it may be better to specify the exact column names in the SELECT rather than using SELECT *.
Hope this helps.
-
great answer thank you. I've played with the exp:query so far and was trying to figure out to make a JOIN with all the custom member fields but got a little confused lol. Any idea how to make that one exp:query to have ALL member info? Amazes me how EE to this date doesn't have this basic information and some type of template tags to display member fields AND custom member fields!– ChiefFeb 5, 2017 at 15:00
-
I have over 2,000 members I will have to pull and create some filtering for... so whatever method is most efficient is what i want to use. your embed method seems pretty straight forward but is the exp:query combining member data AND custom member fields better solution?– ChiefFeb 5, 2017 at 15:03
-
1btw, I'm already using "Smart Members" add-on for the importing features i needed, so using Solspace or another addon just to create this one member page isn't ideal. devot-ee.com/add-ons/smart-members-pro– ChiefFeb 5, 2017 at 15:06
-
added a custom query to my answer that should get you pointed in the right direction. Please let me know if I can help further.– pixldevFeb 6, 2017 at 1:33
I've also been working on attempting this today, and have found that the ExpressionEngine Member data tables have changed a bit. The custom Member Field data is now stored in a separate Table for each field, and can be referenced by using the Member ID identifier.
{exp:query sql="SELECT * FROM exp_members
INNER JOIN exp_member_data_field_1 ON exp_members.member_id = exp_member_data_field_1.member_id
INNER JOIN exp_member_data_field_2 ON exp_members.member_id = exp_member_data_field_2.member_id
WHERE role_id=6 ORDER BY exp_members.join_date DESC"}
<p>{m_field_id_1} {m_field_id_2}</p>
{/exp:query}
Here you can see how I managed to output the Member's First Name and Surname which (for me) are stored in the exp_member_data_field_1
and exp_member_data_field_2
tables.
Oh, and group_id
is now called role_id
.
There is no need to fire custom queries for that. You can do it with any member module:
Free:
https://devot-ee.com/add-ons/zeal-smart-members
Paid:
https://devot-ee.com/add-ons/smart-members-pro
https://devot-ee.com/add-ons/user
You can search for other modules on https://devot-ee.com
I know that this is a bit of an old post, but if anyone stumbles on this, if you are using EE7 (and I think EE6 as well) you can do all of this with the native {exp:member:memberlist ...} Member List tags like so:
{exp:member:memberlist
orderby="screen_name"
group_id = '5' (or whatever group ID you are looking for)
sort="asc"
}
{/exp:member:memberlist}
and then combine it with {member_rows} tags and the {exp:member:custom_profile_data} {my_custon_field} {/exp:member:custom_profile_data} to display as much or as little data as your want.
All the tags are exposed for use in your own templates and don't need to use the native Member" templates at all.
Complete docs are here: https://docs.expressionengine.com/latest/member/memberlist.html
Here: https://docs.expressionengine.com/latest/member/search.html
and here: https://docs.expressionengine.com/latest/member/custom-profile-data.html
Hope it helps. R