PDA

View Full Version : Edit guest username on posts


Paul
08-10-2002, 10:00 PM
Hi,

It aggrevates me that this feature isn't a part of vBulletin, so I've gone and added it myself. Let me know on this thread if you have any problems with it. This hack will allow you to change the username value for any posts made by a guest on your forum. If you don't allow guests to post, don't bother with this hack. :D

I don't have the time to create a screenshot, so you'll have to use some imagination (unless someone else would like to provide one). Just imagine a Username: input box when a moderator with editpost permissions edits a post made by a guest. This will not appear otherwise.

Files to be edited: 1
Template addition: 1

In editpost.php:

Find:

$foruminfo=getforuminfo($threadinfo[forumid]);


ABOVE it, insert:

// Edit username on post hack
if (ismoderator ($threadinfo["forumid"],"caneditposts") && $postinfo[userid]==0) {
if (!$username) {
$postusername = $postinfo["username"];
$postusername = htmlspecialchars($postusername);
eval("\$editusername = \"".gettemplate("editpost_editusername")."\";");
} else {
$postusername = "";
}
}
// End edit username on post hack


Find:

if ($HTTP_POST_VARS['action']=="updatepost") {


BELOW it, insert:

// Edit username of post hack
if ($postinfo[userid]==0) {
$username = trim($username);
$username = eregi_replace("( ){2,}", " ", $username);

if (!$username) {
eval("standarderror(\"".gettemplate("error_nousername")."\");");
}
if ($userinfo=$DB_site->query_first("
SELECT user.*,userfield.*
FROM user,userfield
WHERE (username='".addslashes(htmlspecialchars($username))."' OR
username='".addslashes(eregi_replace("[^A-Za-z0-9]","",$username))."') AND
user.userid=userfield.userid")) {
eval("standarderror(\"".gettemplate("error_usernametaken")."\");");
} else {
$postusername = htmlspecialchars($username);
}
}
// End edit username of post hack


Find:

$DB_site->query("UPDATE thread SET title='".addslashes(htmlspecialchars($title))."', iconid=".intval($iconid)." WHERE threadid=$threadinfo[threadid]");
//$title="";
}


BELOW it, insert:

// Start edit username of post hack
if ($isfirst and $postinfo[userid]==0 and $postinfo[username]!=$postusername) {
$DB_site->query("UPDATE thread SET postusername='".addslashes($postusername)."' WHERE threadid=$threadinfo[threadid]");
}
// End edit username of post hack


Find:

$DB_site->query("UPDATE post SET title='".addslashes(htmlspecialchars($title))."',pagetext='".addslashes($message)."',allowsmilie='$allowsmilie',showsignature='$signa ture',iconid='$iconid'$editedbysql$attachmentsql WHERE postid='$postid'");


BELOW it, insert:

// Start edit username of post hack
if ($postinfo[userid]==0 && $postinfo[username]!=$postusername) {
$DB_site->query("UPDATE post SET username='".addslashes($postusername)."' WHERE postid='$postid'");
}
// End edit username of post hack


Add a template called "editpost_editusername"

Paste the following into the new template and save it (remember to take out the spaces in { firstaltcolor }:

<tr>
<td bgcolor="{ firstaltcolor }" nowrap><normalfont><b>Username:</b></normalfont></td>
<td bgcolor="{ firstaltcolor }"><normalfont><input type="text" class="bginput" name="username" value="$postinfo[username]" size="25" tabindex="1"></normalfont></td>
</tr>


Save and upload editpost.php. All done! :D

wickedfate
06-23-2003, 03:27 AM
nice, got any screenshots?

S.Shady
06-24-2003, 07:01 AM
or use the vb intergrated funtion were a guest can enter a name of their own :)