View Full Version : Your Users Post As Random Users
Hi, this is my first time posting a "hack", so please tell me if I've done something horribly wrong. :p
This is a hack I made mainly for as an April fools joke for my board. You select certain users, and whenever anyone posts, the post is listed as if it was posted by one of those users, chosen at random. On my boards, we chose the users Somebody, Nobody and Anybody.
The code goes in the PHP_INCLUDE_START template. Selecting which users you want it to pick from is easy, you just add and remove array entries. For example, if I wanted it to pick from the users "Joe" and "Bob", who have userids 3 and 4, I would enter ...
$randomuserchoice[1] = array(
'userid' => 3,
'username' => "Joe");
$randomuserchoice[2] = array(
'userid' => 4,
'username' => "Bob");
... where the users are chosen. The full code, with the above example users used, is as follows:
// vvvvvvvvvvvvv The Computer Mutt's Post As Random User Hack vvvvvvvvvvvvv
if ((($_POST['do'] == 'postthread') and ($_POST['sbutton'] == 'Submit New Thread'))
or (($_POST['do'] == 'postreply') and ($_POST['sbutton'] == 'Submit Reply'))
or (($_POST['do'] == 'postreply') and ($_POST['sbutton'] == 'Post Quick Reply')))
{
$bodies = array();
// Chose Users To Select From
// The userid will determine who the post appears to be from in the thread,
// The username will determine who the post appears to be from when you're looking at a list a threads (search, browsing forums, forumhome)
$randomuserchoice[1] = array(
'userid' => 3,
'username' => "Joe");
$randomuserchoice[2] = array(
'userid' => 4,
'username' => "Bob");
$randomuser = rand(1,count($randomuserchoice));
$bbuserinfo['userid'] = $randomuserchoice[$randomuser]['userid'];
$bbuserinfo['username'] = $randomuserchoice[$randomuser]['username'];
}
// ^^^^^^^^^^^^^ The Computer Mutt's Post As Random User Hack ^^^^^^^^^^^^^
If you want to add conditions to when this will apply, such as only applying it to certain users, or only in a given forum, you'd (obviously) just create an if statement and wrap it around all of the code.
You don't need to use real userids and usernames. When I wanted things to be really crazy, I used ...
$randomuserchoice[1] = array(
'userid' => rand(1, 208),
'username' => "Someone");
... 208 being the number of users my board had at the time, so each post would be given to a random user, but would appear as "Someone" while browsing threads.
My members got a kick out of this, I hope you and yours do to. :)
-The Computer Mutt
BluPhoenix
04-01-2005, 07:27 AM
A great idea for a fun April Fools hack, but you might want to put where you should add the code :)
GamerzWorld
04-01-2005, 07:44 AM
It sounds great but id ont get where it goes and how it works. Do i need to change the
$randomuserchoice[1] = array(
'userid' => 3,
'username' => "Joe");
To a userid on my forum to be posted as? Or does that mean that user ID 3 will post as the name Joe. If so is there anyway to completly randomise every user on the forum who posts?
Allan
04-01-2005, 10:47 AM
screen please :)
:p
Oops. The code goes in PHP_INCLUDE_START.
*Goes to change*
@Allan: There's not much to see. Everyone's posts are from one of three users.
It sounds great but id ont get where it goes and how it works. Do i need to change the
$randomuserchoice[1] = array(
'userid' => 3,
'username' => "Joe");
To a userid on my forum to be posted as? Or does that mean that user ID 3 will post as the name Joe. If so is there anyway to completly randomise every user on the forum who posts?Not exactly. I had a hard time explaing this right. This affects every user, unless you change it. It changes the userid and username associated with the post to one that you've provided, randomly seleceted. If that's all you had, all your users would post as whatever user has userid 3, but when viewing threads, it would appear as "Joe" for thead started or most recent poster.
mkdevo
04-01-2005, 11:59 AM
i like it, but it won't revert the posts back to their original poster, will it?
This is awesome. I added an extra if (rand(1, 10) ==1) statement so that it doesn't do it EVERY time. Thanks man!
i like it, but it won't revert the posts back to their original poster, will it?
Nope. It's permanent.
nexialys
04-01-2005, 01:39 PM
so this is a completely useless hack...
reason: your users register with a username... this hack make permanent change so ALL the posts made on the forum are made with random names...
who would use this on a board anyway... logically ?!
so this is a completely useless hack...
reason: your users register with a username... this hack make permanent change so ALL the posts made on the forum are made with random names...
who would use this on a board anyway... logically ?!
nononononono
The POSTS made while this hack are on cant be reversed, but once you remove the code, posts return to normal.
btw, it doesn't seem to work with quick reply
For quick reply to work, make the IF statement say:
if ((($_POST['do'] == 'postthread') and ($_POST['sbutton'] == 'Submit New Thread'))
or (($_POST['do'] == 'postreply') and ($_POST['sbutton'] == 'Submit Reply'))
or (($_POST['do'] == 'postreply') and ($_POST['sbutton'] == 'Post Quick Reply')))
Why does it have to check the button at all though?
GamerzWorld
04-01-2005, 05:00 PM
How do i exempt user ids?
GamerzWorld
04-01-2005, 05:15 PM
Hmm its only working for some usergroups lol
How do i exempt user ids?
This should work:
// vvvvvvvvvvvvv The Computer Mutt's Post As Random User Hack vvvvvvvvvvvvv
if ((($_POST['do'] == 'postthread') and ($_POST['sbutton'] == 'Submit New Thread'))
or (($_POST['do'] == 'postreply') and ($_POST['sbutton'] == 'Submit Reply'))
or (($_POST['do'] == 'postreply') and ($_POST['sbutton'] == 'Post Quick Reply')))
{
if ($bbuserinfo['userid'] != 1 || $bbuserinfo['userid'] != 2){ //Put the exempt IDs in here
$bodies = array();
$randomuserchoice[1] = array(
'userid' => 93,
'username' => "DigitalMocking");
$randomuserchoice[2] = array(
'userid' => 175,
'username' => "jaxxor");
$randomuser = rand(1,count($randomuserchoice));
$bbuserinfo['userid'] = $randomuserchoice[$randomuser]['userid'];
$bbuserinfo['username'] = $randomuserchoice[$randomuser]['username'];
}
}
// ^^^^^^^^^^^^^ The Computer Mutt's Post As Random User Hack ^^^^^^^^^^^^^
Add the IDs to the 2nd IF statement I put in there (See the comment I put in there...). If you need to add more IDs, just put 2 pipes || between the IDs.
EDIT: That code also adds quick reply to the switch...
GamerzWorld
04-01-2005, 05:40 PM
Why are some users still posting in there user name :(
GamerzWorld
04-01-2005, 05:45 PM
Also
if ($bbuserinfo['userid'] != 1 || $bbuserinfo['userid'] != 2){ //Put the exempt IDs in here
$bodies = array(171);
Didnt work :/
Why are some users still posting in there user name :(
They are probably using quick reply, the code OP posted doesn't affect the quick reply.
Also
if ($bbuserinfo['userid'] != 1 || $bbuserinfo['userid'] != 2){ //Put the exempt IDs in here
$bodies = array(171);
Didnt work :/
What is
$bodies = array(171);
edit: Can you post the exact code you're using?
GamerzWorld
04-01-2005, 06:04 PM
Just copied yours.. and added inbetween gaps 171
GamerzWorld
04-01-2005, 06:08 PM
// vvvvvvvvvvvvv The Computer Mutt's Post As Random User Hack vvvvvvvvvvvvv
if ((($_POST['do'] == 'postthread') and ($_POST['sbutton'] == 'Submit New Thread'))
or (($_POST['do'] == 'postreply') and ($_POST['sbutton'] == 'Submit Reply'))
or (($_POST['do'] == 'postreply') and ($_POST['sbutton'] == 'Post Quick Reply')))
{
if ($bbuserinfo['userid'] != 1 || $bbuserinfo['userid'] != 2){ //Put the exempt IDs in here
$bodies = array(171);
$randomuserchoice[1] = array(
'userid' => 1272,
'username' => "Dawolf");
$randomuserchoice[2] = array(
'userid' => 1273,
'username' => "Wayne");
$randomuserchoice[3] = array(
'userid' => 783,
'username' => "Joyfull");
$randomuserchoice[4] = array(
'userid' => 794,
'username' => "Cbc");
$randomuserchoice[5] = array(
'userid' => 797,
'username' => "OpelisGay");
$randomuser = rand(1,count($randomuserchoice));
$bbuserinfo['userid'] = $randomuserchoice[$randomuser]['userid'];
$bbuserinfo['username'] = $randomuserchoice[$randomuser]['username'];
}
}
// ^^^^^^^^^^^^^ The Computer Mutt's Post As Random User Hack ^^^^^^^^^^^^^
I am at a loss for why it doesn't work then. I have turned it off on my board, so I can't test anything. :(
If you just take out one of the IDs, does it work? The $bbuserinfo stuff HAS to be cached by the time it gets to the php_include (I think, LOL).
if ($bbuserinfo['userid'] != 1){ //Put the exempt IDs in here
And I suck at coding, what does the $bodies = array(171); do?
For quick reply to work, make the IF statement say:
if ((($_POST['do'] == 'postthread') and ($_POST['sbutton'] == 'Submit New Thread'))
or (($_POST['do'] == 'postreply') and ($_POST['sbutton'] == 'Submit Reply'))
or (($_POST['do'] == 'postreply') and ($_POST['sbutton'] == 'Post Quick Reply')))
Why does it have to check the button at all though?I'm not certain, I think it's required to make sure the user can't access anything else of the randomly selected user's. I'll update with the quick-reply change. :)
@ Flypaper: Isn't you code saying if the user isn't user one OR isn't user two, so it would allow it for all users?
if (($bbuserinfo['userid'] != 1) AND ($bbuserinfo['userid'] != 2)){This is how I would do it. I'm steal fairly new at this, but I think it's correct.
Since we're checking to see if its not equal to, either AND or OR would work. I think... LOL
Do I fail at basic logic?
Since we're checking to see if its not equal to, either AND or OR would work. I think... LOL
Do I fail at basic logic?
I'm user 1.
Am I not user one? No.
Am I not user two? Yes.
If there are any yeses, it will be executed. So it will run for every member.
Yes, you fail at basic logic. ;)
Well that explains why it didn't work. LOL
rnmcd
11-28-2007, 04:28 PM
Has there been anything similar to this mod that works with 3.6.8?
Has there been anything similar to this mod that works with 3.6.8?
Should be pretty simple to do, I'd think...
rnmcd
11-28-2007, 06:26 PM
Should be pretty simple to do, I'd think...
How could it be pretty simple when you couldn't even get it to work in the original version?:)
How could it be pretty simple when you couldn't even get it to work in the original version?:)
ZING!
I've learned a little since then (or maybe anyway). I had the code at work, but didnt have a chance to test it before I left.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.