PDA

View Full Version : Random User Picker


Dean C
12-31-2004, 10:00 PM
[Random User Picker]

Information

vBulletin Version: 3.0.3


Author: Dean Clatworthy (http://www.deanclatworthy.com)


Copyright: You may use this modification at your own risk. I cannot and will not be held responsible for any damage you may cause to your forums during installation or thereafter. You may not distribute this modification in whole or parts and anyone found doing so faces risk of prosecution. All my modifications are released at vBulletin.org and anyone found releasing them elsewhere also faces risk of prosecution. You may not translate this modification without my prior permission.


Donations: I release my modifications for free. If you wish to donate please contact me and I will give you my details. All donations are graciously appreciated.


Credits: I would like to thank the following people who contributed to the making of this modification.

ChrisBaktis - requested the modification



What does this modification do?
This modification adds a new link to the admincp where you can select a random user. Simple as that!

Installation

1/

Add the following phrases:

Phrase Type: Control Panel User Management
Varname: random_user_picker
Text: Random User Picker

Phrase Type: Control Panel Global
Varname: pick_random_user
Text: Pick Random User

2/

Find in admincp/index.php:

construct_nav_option($vbphrase['generate_mailing_list'], 'email.php?do=genlist', '<br />');

Replace with:

construct_nav_option($vbphrase['generate_mailing_list'], 'email.php?do=genlist', '<br />');
construct_nav_option($vbphrase['pick_random_user'], 'user_random.php', '<br />');

3/

Upload the attached user_random.php to your /admincp/ directory.

Please Click Install!
If you installed this modifcation please click the install button. It'll help you keep up to date with future releases and important bugfixes, security updates.

duncan99
01-01-2005, 02:45 PM
Wondering the purpose of this mod ?!?

Dean C
01-01-2005, 03:14 PM
To pick a random user? Someone requested it, so here it is :)

Dio
01-01-2005, 03:38 PM
This is a great hack!

Question: What would I use this for?

Answer: If you were running a promotion, contest, etc. and needed to randomly pick a winner, this Hack will do it for you. Much like a random number generator gives you a "random number". :)

Dio
01-01-2005, 03:54 PM
Still stumped...It works but is not showing up on my Admin control panel. You can see it's spot between Generate Mailing List and Access Masks.

Dean C
01-01-2005, 04:23 PM
Still stumped...It works but is not showing up on my Admin control panel. You can see it's spot between Generate Mailing List and Access Masks.

Apply step #2 again, my bad :)

Dio
01-01-2005, 05:06 PM
Apply step #2 again, my bad :)
Found it! I loaded the Phrase in the wrong area. Thanks! :D

Xtrm2Matt
01-01-2005, 05:21 PM
Great hack. I'm using this for contests :) (Random username picked out from the contest thread).

Sure beats getting them to email me! :D

Jolten
01-01-2005, 05:25 PM
Wow Dean, nothing like sniping code and not giving credit. Not that this was difficult by any means. I'm sure a lot of people could have done it. Anyway... nice mod. Too bad I was asleep and couldn't do it myself in the past 5 hours.

Dean C
01-01-2005, 05:30 PM
Um snipping code and taking credit? I've been working with PHP/MySQL for almost 5 years now. I don't need to take others code thanks :)

MindTrix
01-01-2005, 05:32 PM
Yeah you tell em :) How is this different from the other mod that randomly picks a user? That one used to pick a user from a thread.

Dean C
01-01-2005, 05:38 PM
I don't know, I did a search after seeing the request and there wasn't a modification that randomnly selects a user from the whole board :) So here it is.

MindTrix
01-01-2005, 05:39 PM
Yup your right there isnt. The other one selects users that post in a certain thread

Jolten
01-01-2005, 05:44 PM
<a href="https://vborg.vbsupport.ru/showthread.php?p=588553#post588553" target="_blank">https://vborg.vbsupport.ru/showt...553#post588553</a>

Dio
01-01-2005, 05:47 PM
https://vborg.vbsupport.ru/showthread.php?p=588553#post588553
I'm lost now granted I am a ultra newbie coder, but Jolten your hack (very good I might add) is doing it in the global.php. Where as Dean C is doing it via a phrase with a call to user_random.php.

I want to make sure that I understand how he stole your code because they appear to be two different things.

Dean C
01-01-2005, 05:53 PM
Well you'll have to excuse me because I may be wrong here, but last time I checked there was only one way to run a MySQL query to gain a random record from a table? I don't see what the big deal is here? Do you want credits in my first post or something?

I wrote that query without even looking at your post buddy so :)

Koutaru
01-01-2005, 06:07 PM
Dean did not steal that code as you can see he missed the WHERE and the code isn't that difficult. That's the first way anyone would probably think of to grab a random user from the user table.

The WHERE which, by the way, I think should be put in so you don't grab banned members or members with no posts. If not, maybe an option to select WHERE clauses.

Dan
01-01-2005, 06:45 PM
This is a nice quirky mod thanks for sharing it Dean

theArchitect
01-01-2005, 08:34 PM
last time I checked there was only one way to run a MySQL query to gain a random record from a table? I don't see what the big deal is here? Do you want credits in my first post or something?We could be in the wrong here. It is possible he invented MySQL and as such came up with the command. If so I suppose he would be entitled to a thank you.

Jolten
01-01-2005, 10:05 PM
It was really no big deal. Just kind of would have liked the opportunity to finish what I had started.

If you were engaged in a thread with someone about a request I certainly wouldn't just step in.

SVTBlackLight01
01-01-2005, 10:18 PM
This has been requested since a hack like this was released for vb2, and AFAIK hasn't ever been done. Is it possible to modify this to give a greater weight to those with more posts?

Zacharicus
01-02-2005, 12:23 AM
Fantastic, I needed one of these to pick a winner of a Half Life 2 contest. Just gotta sign up to win :D

Thanks!!

Dean C
01-02-2005, 12:26 AM
This has been requested since a hack like this was released for vb2, and AFAIK hasn't ever been done. Is it possible to modify this to give a greater weight to those with more posts?

I spent a few minutes ago just adding some filters. Will release an updated file within the next couple of days with a few options to add bias ;)

SVTBlackLight01
01-02-2005, 12:31 AM
You're Awesome!! :banana: Looking forward to it. :D

ChrisBaktis
01-02-2005, 01:53 AM
Thank you - Thank you - Thank you!!!

I requested this hack because I run a sports card trading site. On this site we receive product from sponsors that we give out to members. I was looking for something to pick a random user every month from the entire member base - not just a thread where a member posts.

Thank you again for the hack!

ChrisBaktis
01-02-2005, 01:55 AM
I saw that you are going to add a few features to this hack - If I can suggest one I would like to be able to eliminate members with 0 posts.

T3MEDIA
01-02-2005, 10:47 AM
Well get this. I want something like this (http://match.com/search/searchSubmit.aspx?RN=2221782&PN=1&DO=2&sid=D0D1A819-9FFC-43F4-ADFD-1FDCE25FE8BB&trackingid=0&theme=213&lid=1000005) that would keep my style but show users profile picture that has a photo.

Never mind the sorting and all that. Just can that be done?

I can do it and have done it in memberfind (http://www.sprnch.com/forums/memberlist.php?do=getall&page=2&ltr=&pp=10&order=asc&postslower=0&postsupper=0&sort=username&ausername=&homepage=&icq=&aim=&yahoo=&msn=&joindateafter=&joindatebefore=&lastpostafter=&lastpostbefore=). but randomly and "must have photo"
Nope and yet to find anyone that can do it or has the time.

HA! Do that...

Dean C
01-03-2005, 11:07 AM
File updated with new filters:

Exclude unregistered/unconfirmed users
Eliminate users with less than or equal to x posts
Eliminate users with greater than or equal to x posts


P.S. I'm too lazy to carry on making new phrases :p

SnowBot
01-03-2005, 12:09 PM
Simple but effective :) nice hack Dean :)

1 suggestion :) Maybe have a filter by group ? Maybe do it by group ID as i would like to pick users but not say staff.

Dean C
01-03-2005, 12:28 PM
So have some tickboxes to filter by usergroup perhaps :)?

SnowBot
01-03-2005, 12:51 PM
Yer that sounds good :)

Dean C
01-03-2005, 03:42 PM
Ok reupload user_random.php again, it has every search option you could possibly need in there :)

SnowBot
01-03-2005, 04:23 PM
hehehe :) abit overkill but nice :)

Dean C
01-03-2005, 04:29 PM
Well I thought I might as well add it all, after looking at user.php it was easy to do :)

jamesk
01-05-2005, 03:58 AM
Is it possible to set this to a specific usergroup??

SVTBlackLight01
01-05-2005, 05:21 AM
Yes. It works just like searching for users. Just select which usergroup(s) to choose from.

ChrisBaktis
01-05-2005, 12:31 PM
Thanks for the filters!

Dean C
01-05-2005, 03:01 PM
Is it possible to set this to a specific usergroup??

Yes, it's an option when picking a user :)

mekro
01-13-2005, 08:43 AM
Hi can you help me with a small error i have it is below:

Invalid SQL:
SELECT
user.userid,
usergroupid,
birthday_search,
username,
posts
FROM
vb_user
LEFT JOIN vb_userfield AS userfield ON(userfield.userid = user.userid)
LEFT JOIN vb_usertextfield AS usertextfield ON(usertextfield.userid = user.userid)
WHERE
1=1
ORDER BY
RAND()
LIMIT
1

mysql error: Unknown table 'user' in field list

mysql error number: 1109

Thanks for any help.

Kirk

Marco van Herwaarden
01-13-2005, 12:22 PM
Change:
FROM
vb_user


Into:
FROM
vb_user AS user

Freezerator
01-24-2005, 09:42 AM
^^ that would be great :)

I want to start a lottery for one usergroup only :)

I have installed this current one, it's working fine :)
Thanks!

Dean C
01-28-2005, 03:31 PM
Just updated the user_random.php file with Marco's fix, need to make a habit out of using aliases now :)

SupraT
02-28-2005, 11:26 PM
Nice little hack, was wanting something to make giveaways easier. Thanks!

Dean C
03-03-2005, 01:39 PM
Glad you like it SupraT :)

zachlee
03-11-2005, 06:15 PM
Thanks Dean, Works perfectly!!

/clicks install

Sleepyk
03-13-2005, 10:43 PM
works great good deal

tomwilkinson2
04-21-2005, 10:39 AM
Thanks Dean!

I have just installed this successfully, but I was wondering whether you or someone could help me modify it so that it only picks registered users that have posted something, anything, over the last seven days?

We want to give some freebies to people each week but only pick from the recent posters.

Any help would be really appreciated.

Thanks again....

Freezerator
01-06-2006, 08:40 AM
Hi Dean C,

thanks for this hack, i have been using it alot. Will there be an update of this hack to 3.5.x?
Thanks in advance.

lazyseller
01-06-2006, 07:13 PM
Yeah i been looking for something simliar as well but misplaced this post for a request for 3.5

hoopsta
05-01-2006, 07:15 PM
will this work with 3.5?

Camz
08-10-2006, 07:46 PM
will this work with 3.5?
BUMP!!!

Cebby
09-05-2006, 06:51 AM
Will this work on 3.6?