View Full Version : Make guests give a name when posting or replying
bairy
12-20-2005, 10:00 PM
One of the big problems with guest postings is the majority of them show up as "Unregistered" due to the user's laziness.
With a little checking you can 'make' them give a name. Simply put when the user submits the form, it checks the username field (which only shows when you're not logged in) for 'Unregistered' or emptyness, and if it's either, shows an alert to the user.
There are two usable methods:
1. Javascript based. This checks the username as soon as you click submit and pops up a dialog if it's 'Unregistered' or blank. This method is more instant but screws up wysiwyg input. If you use or plan to use wysiwyg, go the second option.
2. vB checking based. This allows the submit (or preview) to go and produces an error in the same way as 'post too short' or similar.
For 1, see post 2.
For 2, see post 3.
Click install if you like. Don't if you don't want to. I don't really care :)
bairy
12-22-2005, 09:17 PM
Javascript version:
Open newpost_usernamecode
Find (near the bottom)
<td class="smallfont" colspan="2"><input type="text" class="bginput" name="username" value="$bbuserinfo[username]" size="50" style="margin-top:1px" /></td>
Replace with
<td class="smallfont" colspan="2"><input type="text" class="bginput" name="username" value="$bbuserinfo[username]" size="50" style="margin-top:1px" onfocus="javascript: if (this.value == 'Unregistered') { this.value = ''; }" /></td>
Open newthread
Find (almost at the top)
<form action="newthread.php" method="post" name="vbform"<if condition="!is_browser('webtv')"> onsubmit="return validatePost(this, this.subject.value, $vboptions[postminchars], $vboptions[postmaxchars]);" onreset="vB_RESET(this);"</if>>
Replace with
<form action="newthread.php" method="post" name="vbform"<if condition="!is_browser('webtv')"> onsubmit="javascript:if ((document.vbform.username.value == 'Unregistered') || (document.vbform.username.value == '')) { alert('Please insert a nickname or an online name you use, so that you can be identified from other unregistered users'); document.vbform.username.focus(); return false; } return validatePost(this, this.subject.value, $vboptions[postminchars], $vboptions[postmaxchars]);" onreset="vB_RESET(this);"</if>>
Open newreply
Find (again, near the top)
<form action="newreply.php" name="vbform" method="post"<if condition="!is_browser('webtv')"> onsubmit="return validatePost(this, 0, $vboptions[postminchars], $vboptions[postmaxchars]);" onreset="vB_RESET(this);"</if>>
Replace with
<form action="newreply.php" method="post" name="vbform"<if condition="!is_browser('webtv')"> onsubmit="javascript:if ((document.vbform.username.value == 'Unregistered') || (document.vbform.username.value == '')) { alert('Please insert a nickname or an online name you use, so that you can be identified from other unregistered users'); document.vbform.username.focus(); return false; } return validatePost(this, this.subject.value, $vboptions[postminchars], $vboptions[postmaxchars]);" onreset="vB_RESET(this);"</if>>
bairy
01-07-2006, 10:05 PM
vB checking version:
Step 1.
Add phrase
Phrase Type: Front-End Error Messages
Varname: notuniqueusername
Text: Using the "Your username" input box just below, please insert a nickname or an online name you use, so that you can be identified from other unregistered users.
(The Text can be whatever you like)
Step 2.
Open includes/functions_newpost.php
Find (around line 767):
if (empty($post['username']))
{
eval('$errors[] = "' . fetch_phrase('nousername', PHRASETYPEID_ERROR) . '";');
}
Add under:
else if ($post['username'] == 'Unregistered' OR $post['username'] == '')
{
eval('$errors[] = "'. fetch_phrase('notuniqueusername', PHRASETYPEID_ERROR) . '";');
}
Step 3 - optional. It simply clears the "Your username" box if it's clicked on and says 'Unregistered'
Open template newpost_usernamecode
Find (near the bottom)
<td class="smallfont" colspan="2"><input type="text" class="bginput" name="username" value="$bbuserinfo[username]" size="50" style="margin-top:1px" /></td>
Replace with:
<td class="smallfont" colspan="2"><input type="text" class="bginput" name="username" value="$bbuserinfo[username]" size="50" style="margin-top:1px" onfocus="javascript: if (this.value == 'Unregistered') { this.value = ''; }" /></td>
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.