I wonder if it’s possible to display random 3 members from a certain group along with their avatars, names and some custom field data in a widget on a homepage?
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
June 15, 2011 12:50pm
Subscribe [2]#1 / Jun 15, 2011 12:50pm
I wonder if it’s possible to display random 3 members from a certain group along with their avatars, names and some custom field data in a widget on a homepage?
#2 / Jun 16, 2011 7:05am
PipSpratt,
You have the Custom Profile Data Tag available to you which will give you one instance of a member profile
I would suggest maybe using the Query Module for this
{exp:query sql="SELECT screen_name, email, location FROM exp_members WHERE group_id = '1' ORDER BY random DESC LIMIT 3"}
{screen_name}
{email}
{location}
{/exp:query}Does that help?
#3 / Jun 16, 2011 7:20am
thank you John, I was thinking about using Query Module but when I put your code on my website (I only changed group_id) all I get is:
M20o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr
...
#4 / Jun 16, 2011 7:23am
PipSpratt,
Try it without the random bit for the moment
{exp:query sql="SELECT screen_name, email, location FROM exp_members WHERE group_id = '1' DESC LIMIT 3"}#5 / Jun 16, 2011 7:27am
again:
M20o93H7pQ09L8X1t49cHY01Z5j4TT91fGfr
#6 / Jun 16, 2011 7:29am
PipSpratt,
Can I confirm that you have the query module installed?
Have you nested this within any other tag say like the Channel Entries tag?
Test this on a blank template with nothing else in there only the code above
Try some of the other examples of the Query Docs page too
#7 / Jun 16, 2011 7:39am
yes, you’re correct, I forgot to install Query 😊
But now I’ve installed it and when I want to access my homepage I see blank page. Here’s my code:
#8 / Jun 16, 2011 7:43am
all right, it works with
{exp:query sql="SELECT screen_name, email, location FROM exp_members WHERE group_id = '6' ORDER BY RAND() LIMIT 3"}
instead
{exp:query sql="SELECT screen_name, email, location FROM exp_members WHERE group_id = '6' DESC LIMIT 3"}
thanks 😊
#9 / Jun 16, 2011 8:24am
Excellent! We got there in the end 😊 Feel free to start a new thread if you have any more questions