how to show most recent members
macuhail - August 27, 2007 - 19:01
I want to show the most recent 5 to 10 recently signed up users on the front page. Is there a module for this.
Also we might prefer to show 5 to 10 random users whenever the front page loads. Is there also an easy to do this?
Thanks for any suggestions.

Most recent members
Hi.
For the first requirement, just enable the 'Who's New' block from Administer > Blocks.
Pete.
=-=
as far as the second request is concerned, there is no module, setting, or block to do this, one would have to write a custom DB query to pull the random users from the users table.
_________________________________________________________________________
This has been a broadcast of the public Drupal Search system. We thank you for watching! : )
custom random member block
Create a custom block, and insert the following code. Ensure that the block is set up as php.
<?php$result = db_query_range('SELECT * FROM {users} WHERE status != 0 AND access != 0 ORDER BY RAND()', 0,1);
while ($account = db_fetch_object($result)) { $items[] = $account;}
$output = "<br><table cellpadding='0' cellspacing='0' border='0'><tr><td align='middle'> </td><td align='middle'>";
$output .= theme('user_picture', $items[0]);
$output .= "</td></tr><tr><td align='middle' colspan='2'>";
$output .= theme('user_list', $items);
$output .= "</td></tr></table>";
print $output;
?>
This only shows a random member that is active. The picture and name will be linked to the profile if person is logged in, otherwise no links.
I had to use a table to format because the user_list call was messing up the formatting (not badly, it just adds a bullet to the name) and I couldn't figure out another way to either just print the name as plain text or link it up to the profile without having the bullet added. I had thought using $items[1] would work but it doesn't.
Also spent some time trying to figure out how to pull in a line or two from the profile_values table (like location) but after a few hours I gave up, 'cause nothing was working right.
this is better
This version does the same as above, but the formatting is improved.
<?php$result = db_query_range('SELECT * FROM {users} WHERE status != 0 AND access != 0 ORDER BY RAND()', 0,1);
while ($account = db_fetch_object($result)) { $items[] = $account;}
$output = "<br><div align='center'>";
$output .= theme('user_picture', $items[0]);
$output .= theme('username', $items[0]);
$output .= "</div>";
print $output;
?>
Thanks for the input. This
Thanks for the input. This is a big help.
Whoops, missed the part
Whoops, missed the part about the number of random users you want to show.
You need to change this part:
ORDER BY RAND()', 0,1
Switch the "1" to 5, or 10. This should increase the number of results returned.
The above didn't work. This generates a Who's New with pictures
I tried the above, then I realized it's missing a loop. This may not be the cleanest way, but it works (in a block):
<?php$result = db_query_range('SELECT * FROM {users} WHERE status != 0 AND access != 0 ORDER BY created DESC', 0, 6);
while ($account = db_fetch_object($result)) {$items[] = $account;}
$n=0;
while ($items[$n]) {
$output = "<br><div align='center'>";
$output .= theme('user_picture', $items[$n]);
$output .= theme('username', $items[$n]);
$output .= "</div>";
print $output;
$n++;
}
?>
Note that I used ORDER BY created instead of RAND() for my needs
Edwin M. Basye
http://sitesthatgrow.com
how to make it display horizontal?
The above code works great! but how to display it horizontally instead of vertically?
=-=
name the div, give it some css to in style .css float left ?
_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )
Thanks for the help
But I have no clue what you're talking about at all. I think I must learn some php.
=-=
you mean css. while the snippet you have there is php, you need to style it using css
_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )
This is easily accomplished
This is easily accomplished using the views module, I believe you may have to also install the usernode module and use that to show the members names / picture.
I'm tried out these two
I'm tried out these two modules. It only lets me view the pictures vertically either in table view or list view. I want this view if possible:
Picture1 Picture2 Picture3 Picture4
Picture5 Picture6 Picture7 Picture8
Any fields/arguments/filters/exposed filters/sort criteria I need to change to get this view?