vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Make guests give a name when posting or replying (https://vborg.vbsupport.ru/showthread.php?t=103464)

bairy 12-20-2005 10:00 PM

Make guests give a name when posting or replying
 
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)
Code:

<td class="smallfont" colspan="2"><input type="text" class="bginput" name="username" value="$bbuserinfo[username]" size="50" style="margin-top:1px" /></td>
Replace with
Code:

<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)
Code:

<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
Code:

<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)
Code:

<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
Code:

<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):
Code:

                if (empty($post['username']))
                {

                        eval('$errors[] = "' . fetch_phrase('nousername', PHRASETYPEID_ERROR) . '";');

                }

Add under:
Code:

                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)
Code:

<td class="smallfont" colspan="2"><input type="text" class="bginput" name="username" value="$bbuserinfo[username]" size="50" style="margin-top:1px" /></td>
Replace with:
Code:

<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>


All times are GMT. The time now is 10:52 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.01044 seconds
  • Memory Usage 1,725KB
  • 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
  • (10)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete