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

slumbermann 02-10-2010 05:06 AM

Quote:

Originally Posted by kevinfx (Post 1978872)
i got the links to the profiles, but not profile picture? what's wrong? thanks

could you please give me your website url...

kevinfx 02-10-2010 05:07 AM

oh i'm using vb 4.0, maybe that's why? i haven't upgraded yet

asj 02-10-2010 05:13 AM

Quote:

oh i'm using vb 4.0, maybe that's why? i haven't upgraded yet
Same problem

slumbermann 02-10-2010 05:16 AM

Quote:

Originally Posted by kevinfx (Post 1978880)
oh i'm using vb 4.0, maybe that's why? i haven't upgraded yet

Quote:

Originally Posted by asj (Post 1978883)
Same problem

haven't tried on vb 4.0 because i'm running this on 4.0.1... but will try to look into vb 4.0 too and see how it goes...

slumbermann 02-10-2010 05:19 AM

Quote:

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

please try this code instead for avatar.

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();


Boosted Panda 02-10-2010 02:20 PM

Quote:

Originally Posted by slumbermann (Post 1978886)
please try this code instead for avatar.

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();


Awesome! Thank you sir!

Talk-Pets 02-10-2010 03:19 PM

Could it leave out members with no avatars and just shows the ones that has?

slumbermann 02-11-2010 12:11 AM

Quote:

Originally Posted by Boosted Panda (Post 1979146)
Awesome! Thank you sir!

ur welcome
Quote:

Originally Posted by Talk-Pets (Post 1979173)
Could it leave out members with no avatars and just shows the ones that has?

yes, only members with profile picture or avatars will be shown.

kevinfx 02-11-2010 02:29 AM

were you able to figure out what wrong with using this code with vb version 4.0?

thank you

blake247 02-11-2010 03:08 AM

Thanks for the tip! Great widget!

slumbermann 02-11-2010 04:37 AM

Quote:

Originally Posted by kevinfx (Post 1979680)
were you able to figure out what wrong with using this code with vb version 4.0?

thank you

Hi,

I just tested the code with vb 4.0 and it works with no problem. Please make sure your user have profile picture or avatars uploaded, else there will be no picture shown.

slumbermann 02-11-2010 04:38 AM

Quote:

Originally Posted by blake247 (Post 1979705)
Thanks for the tip! Great widget!

Ur welcome... :)

kevinfx 02-11-2010 05:13 AM

that's weird because the usernames listed do have profile pictures .... Do i need to change anything in the code?
my vb is 4.0 patch level 1. also i store profile pics and avatars on the server (file system) not in the database.... would that make a different?

slumbermann 02-11-2010 05:24 AM

Quote:

Originally Posted by kevinfx (Post 1979748)
that's weird because the usernames listed do have profile pictures .... Do i need to change anything in the code?

You don't need to change anything in the code, you just need to choose either to use the profile picture or avatar, currently i separated the code, so each will only work with one source, i will try to integrate both into the code.

when you create the widget, it show empty box or what? could you please explain your problem, i will try my best to help

kevinfx 02-11-2010 05:39 AM

when i create the widget, it shows some code in there. I replaced it everything with your code.

Thank you

slumbermann 02-11-2010 05:44 AM

Quote:

Originally Posted by kevinfx (Post 1979763)
when i create the widget, it shows some code in there. I replaced it everything with your code.

Thank you

and when you add it to your layout manager? what are shown on the front page?

kevinfx 02-11-2010 05:49 AM

just 3 links (user names) to profiles without the profile pictures... looks like the widget was able to pull all users that have profile pix, but unable to display profile pix on the CMS

because i store profile pix on the server instead db, the profile pix URL is, for example :

/forum/customprofilepics/profilepic1_1.gif ..... not image.php?u=xxx

slumbermann 02-11-2010 06:07 AM

Quote:

Originally Posted by kevinfx (Post 1979768)
just 3 links (user names) to profiles without the profile pictures... looks like the widget was able to pull all users that have profile pix, but unable to display profile pix on the CMS

because i store profile pix on the server instead db, the profile pix URL is, for example :

/forum/customprofilepics/profilepic1_1.gif ..... not image.php?u=xxx

ok, so that was the reason, could you please PM me your website url?

Martyh 02-11-2010 07:30 AM

Can it be set to pull from a specific user group ?

slumbermann 02-11-2010 08:47 AM

Quote:

Originally Posted by Martyh (Post 1979808)
Can it be set to pull from a specific user group ?

yes you can, but there additional code to be added, how many group do you need? just one or some groups?

Martyh 02-13-2010 01:33 AM

Hi, sorry for the late response, just one group.

mobilewo 02-14-2010 04:05 AM

hello sir can you please help me how to add this widget in profile page

(I hope this is good idea for connecting friends)

:):):)

Pro-eSports.com 02-14-2010 04:38 AM

Where on the forum will it show up? Screenshot or demo link maybe? :)

australiaforum 02-14-2010 12:18 PM

I am having the same problem where just the link is showing up. I am on 4.01.

http://balipod.com

nomoreturn 02-14-2010 12:36 PM

Quote:

Originally Posted by australiaforum (Post 1982070)
I am having the same problem where just the link is showing up. I am on 4.01.

http://balipod.com

I also have same problem and i'm useing vb 4.0.1
http://www.mastdunya.com

eternal_ 02-15-2010 09:23 PM

can this be used for the forums sidebar instead of the cms?

Pangramma 02-19-2010 09:48 PM

Is it possible to only show the ACTIVE members?

Nice widget ;)

iadventure 02-21-2010 09:08 PM

I installed it, but it only shows link to names, no photo. CAn you help?

http://jk-adventure.com/JKA/content.php

Scroll down on left side

alfanexus 02-28-2010 07:37 AM

I got the same problem with the photo not being shown. Using vb 4.0.2

Doctor Death 03-08-2010 01:34 PM

This works great on my 4.0.2 install. Is there an easy way to ensure that images are resized appropriately? A few user images are larger than the frame.

Thanks and great work.


All times are GMT. The time now is 01:27 PM.

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.02152 seconds
  • Memory Usage 1,845KB
  • 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
  • (9)bbcode_code_printable
  • (20)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
  • (40)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