vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=245)
-   -   vBulletin CMS Widgets - Widget - Show random members with picture (https://vborg.vbsupport.ru/showthread.php?t=235460)

slumbermann 02-09-2010 10:00 PM

Widget - Show random members with picture
 
1 Attachment(s)
#Function:
  • Show random members which have profile picture
  • Clickable picture and username to go to member's profile page

#Installation:
  1. Go to Admin CP > vBulletin CMS > Widgets > create new widget
  2. Widget type > PHP Direct Execution . Title > Random Members . Description > Show random members
  3. click save
  4. then click configure and put the code below

#code to use custom profile picture as the source of picture

Code:

$member_count = 3;

  ob_start();
  require_once('./includes/functions_user.php');
  require_once('./includes/functions_bigthree.php');
  // Get Random Members
  $newusers_get = vB::$db->query_read("
    SELECT ".TABLE_PREFIX."user.userid AS userid, ".TABLE_PREFIX."user.username AS username, ".TABLE_PREFIX."customprofilepic.dateline AS dateline FROM ".TABLE_PREFIX."customprofilepic
        LEFT JOIN ".TABLE_PREFIX."user
                        ON ".TABLE_PREFIX."customprofilepic.userid=".TABLE_PREFIX."user.userid
    WHERE ".TABLE_PREFIX."customprofilepic.visible = 1
  ORDER BY RAND()
  LIMIT $member_count");
  $output_bits = '<p align="center"';
  while($newuser = vB::$db->fetch_array($newusers_get))
  {
        $output_bits .= '<a href="member.php?u='.$newuser[userid].'"><img src="image.php?u='.$newuser[userid].'&dateline='.$newuser[dateline].'&type=profile" alt="'.$newuser[username].'"/><br />'.$newuser[username].'</a><br />';
  }
  $output_bits .= '</p>';
  $output = $output_bits;
  ob_end_clean();

#code if you want to use custom avatar as the main source for the picture

Code:

$member_count = 3;

  ob_start();
  require_once('./includes/functions_user.php');
  require_once('./includes/functions_bigthree.php');
  // Get Random Members
  $newusers_get = vB::$db->query_read("
    SELECT ".TABLE_PREFIX."user.userid AS userid, ".TABLE_PREFIX."user.username AS username, ".TABLE_PREFIX."customavatar.dateline AS dateline FROM ".TABLE_PREFIX."customavatar
        LEFT JOIN ".TABLE_PREFIX."user
                        ON ".TABLE_PREFIX."customavatar.userid=".TABLE_PREFIX."user.userid
    WHERE ".TABLE_PREFIX."customavatar.visible = 1
  ORDER BY RAND()
  LIMIT $member_count");
  $output_bits = '<p align="center"';
  while($newuser = vB::$db->fetch_array($newusers_get))
  {
        $output_bits .= '<a href="member.php?u='.$newuser[userid].'"><img src="image.php?u='.$newuser[userid].'&dateline='.$newuser[dateline].'" alt="'.$newuser[username].'"/><br />'.$newuser[username].'</a><br />';
  }
  $output_bits .= '</p>';
  $output = $output_bits;
  ob_end_clean();

Note: You can edit the amount of members you want to show by changing the $member_count from 3 to whatever value you want.

Boosted Panda 02-10-2010 01:49 AM

Can you make this avatar instead?

slumbermann 02-10-2010 01:56 AM

Quote:

Originally Posted by Boosted Panda (Post 1978800)
Can you make this avatar instead?

yes sure... give me some time then i will make an avatar version too...

slumbermann 02-10-2010 02:01 AM

Quote:

Originally Posted by Boosted Panda (Post 1978800)
Can you make this avatar instead?

to show the profile picture using avatar function use this code instead

Code:

$member_count = 3;

  ob_start();
  require_once('./includes/functions_user.php');
  require_once('./includes/functions_bigthree.php');
  // Get Random Members
  $newusers_get = vB::$db->query_read("
    SELECT user.userid AS userid, user.username AS username, customavatar.dateline AS dateline FROM ".TABLE_PREFIX."customavatar
        LEFT JOIN ".TABLE_PREFIX."user
                        ON ".TABLE_PREFIX."customavatar.userid=".TABLE_PREFIX."user.userid
    WHERE customprofilepic.visible = 1
  ORDER BY RAND()
  LIMIT $member_count");
  $output_bits = '<p align="center"';
  while($newuser = vB::$db->fetch_array($newusers_get))
  {
        $output_bits .= '<a href="member.php?u='.$newuser[userid].'"><img src="image.php?u='.$newuser[userid].'&dateline='.$newuser[dateline].'" alt="'.$newuser[username].'"/><br />'.$newuser[username].'</a><br />';
  }
  $output_bits .= '</p>';
  $output = $output_bits;
  ob_end_clean();


Boosted Panda 02-10-2010 03:24 AM

That didn't work

slumbermann 02-10-2010 03:46 AM

Quote:

Originally Posted by Boosted Panda (Post 1978841)
That didn't work

do you use custom avatar?

blake247 02-10-2010 04:04 AM

Is there anyway to make the profile pics smaller?

cykelmyggen 02-10-2010 04:20 AM

I get a database error on content.php every time I put this widget on!?
Code:

Database error in vBulletin 4.0.1:

Invalid SQL:

    SELECT user.userid AS userid, user.username AS username,
customprofilepic.dateline AS dateline FROM vbcustomprofilepic
        LEFT JOIN vbuser
                        ON vbcustomprofilepic.userid=vbuser.userid
    WHERE customprofilepic.visible = 1
  ORDER BY RAND()
  LIMIT 3;

MySQL Error  : Unknown column 'user.userid' in 'field list'
Error Number  : 1054


slumbermann 02-10-2010 04:34 AM

Quote:

Originally Posted by blake247 (Post 1978854)
Is there anyway to make the profile pics smaller?

yes you can add in width and height to the img code example like below:

Code:

        $output_bits .= '<a href="member.php?u='.$newuser[userid].'"><img src="image.php?u='.$newuser[userid].'&dateline='.$newuser[dateline].'" alt="'.$newuser[username].' width="50px" height="50px""/><br />'.$newuser[username].'</a><br />';

Quote:

Originally Posted by cykelmyggen (Post 1978858)
I get a database error on content.php every time I put this widget on!?
Code:

Database error in vBulletin 4.0.1:

Invalid SQL:

    SELECT user.userid AS userid, user.username AS username,
customprofilepic.dateline AS dateline FROM vbcustomprofilepic
        LEFT JOIN vbuser
                        ON vbcustomprofilepic.userid=vbuser.userid
    WHERE customprofilepic.visible = 1
  ORDER BY RAND()
  LIMIT 3;

MySQL Error  : Unknown column 'user.userid' in 'field list'
Error Number  : 1054


hurmm that's weird, please try this code instead

Code:

$member_count = 3;

  ob_start();
  require_once('./includes/functions_user.php');
  require_once('./includes/functions_bigthree.php');
  // Get Random Members
  $newusers_get = vB::$db->query_read("
    SELECT ".TABLE_PREFIX."user.userid AS userid, ".TABLE_PREFIX."user.username AS username, ".TABLE_PREFIX."customprofilepic.dateline AS dateline FROM ".TABLE_PREFIX."customprofilepic
        LEFT JOIN ".TABLE_PREFIX."user
                        ON ".TABLE_PREFIX."customprofilepic.userid=".TABLE_PREFIX."user.userid
    WHERE customprofilepic.visible = 1
  ORDER BY RAND()
  LIMIT $member_count");
  $output_bits = '<p align="center"';
  while($newuser = vB::$db->fetch_array($newusers_get))
  {
        $output_bits .= '<a href="member.php?u='.$newuser[userid].'"><img src="image.php?u='.$newuser[userid].'&dateline='.$newuser[dateline].'&type=profile" alt="'.$newuser[username].'"/><br />'.$newuser[username].'</a><br />';
  }
  $output_bits .= '</p>';
  $output = $output_bits;
  ob_end_clean();


kevinfx 02-10-2010 04:59 AM

i got the links to the profiles, but not profile picture? what's wrong? thanks


All times are GMT. The time now is 08:48 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03484 seconds
  • Memory Usage 1,758KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_code_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete