Random member with avatar and profile fields on front page - Drupal

I have a website in Drupal 5.x.

I need to have ONE random user at a time on the front page (using advanced front page module) with their avatar, profile_organame, profile_briefdescription, profile_profile, profile_location (etc).

But I only want random members WITH an avatar to be shown... I need the others without an Avatar NOT to be shown.

Need this pretty speedy, thanks.
Lambo_OOAsked:
Who is Participating?
 
Lambo_OOConnect With a Mentor Author Commented:
I managed to figure this out - here it is if someone else needs info.

I could however do with help on limiting the number of characters printed from profile_profile if anyone knows how to limit this output - css doesnt really seem to help.

<?php
$count = 1;

$no_avatar = "http://www.mywebsite.com/files/systemfiles/jitter-1.PNG";
$result = db_query_range(db_rewrite_sql("SELECT * FROM {users} u ORDER BY RAND()"), 0, $count);
  while ($user_info = db_fetch_object($result)) {
    if($user_info->uid){
      if($user_info->picture){
      print "<a href=\"/user/$user_info->uid\" title=\"View $user_info->name's profile.\">";  print '<img src="/'.$user_info->picture.'" height=90 width=90 alt="Visit this user profile.">'; print '</a>';
profile_load_profile($user_info);
     print "<html><br><br></html>";
     print $user_info->name;
     print "<html><br><br></html>";
     print $user_info->profile_BriefDescription;
     print "<html><br><br></html>";
     print $user_info->profile_profile;
     print "<html><br><br></html>";
     print "<html> ... </html>";


}
       else {
      $result = db_query_range(db_rewrite_sql("SELECT * FROM {users} u ORDER BY RAND()"), 0, $count);
       }
    }

  }
?>


0
 
oliverpoldenCommented:
You can do this with the views module.

Set sort order to Global: Random for your random order. Everything else should hopefully be self explanatory.
0
 
Lambo_OOAuthor Commented:
Oliver, I dont know how to use views on the front page using the advanced front page module, Ideally, looking for a quick code snippet.

thanks
0
 
Lambo_OOAuthor Commented:
This may help others - I solved the character limit using substr. np.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.