vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Auto Username - Request (https://vborg.vbsupport.ru/showthread.php?t=48692)

Rose 02-08-2003 05:41 PM

Auto Username - Request
 
I've a request. I've been combing the hacks db, and haven't found it yet, so here we go. Many thanks to my husband who inspired me to think of this (if it's not been thought of before, of course)

Anyway...I want my members to use their first and last name for their username (it's a private, member's only board). However, for whatever reason, some of these people aren't grasping that concept and they are coming up with off-the-wall usernames which makes it really hard for other members to use the member list to effectively find them.

Basically what I want is this - upon registration instead of having a "username" field, I want two fields - "First Name" and "Last Name". Upon registration, these two fields would be kept separately for sorting (details below), but it would generate a username for the member - obviously displaying the username so they know how to log back in. If I were to register with my first and last name like so - "Rose" and "Schmuckatelli", it'd generate a username for me like "Rose Schmuckatelli" (Space in between is preferred).

Now, the reason I want the first & last name fields to be kept separate is so that members can easily search the memberlist either by "First" or "Last" name sort orders.

So, this might be two hacks, it might be one big(ish) hack. But is anyone intersted?

Xenon 02-08-2003 06:21 PM

well, you have to add two required profilefields and then just combine them when inserting the username into the DB.
really not a hard problem, but what should happen when two people have the same name? (that could happen not so rarely, Hans Meier is a very popular name in germany for example....)

Rose 02-08-2003 06:38 PM

Quote:

Originally posted by Xenon
well, you have to add two required profilefields and then just combine them when inserting the username into the DB.
really not a hard problem, but what should happen when two people have the same name? (that could happen not so rarely, Hans Meier is a very popular name in germany for example....)


I believe NTLDR is going to help with this hack - I'm completely inexperienced when it comes to writing php. But anyway...you present a very good problem - dupe usernames. Since the site is limited to basically members of our Club, this shouldn't be too big of a problem. Those father/son's who do have the same names will need to enter a suffix like "Jr." or something. however, there is always a chance for error so a nice little error message would be good. Something stating "The Name(s) you entered are already registered. Have you registered before and forgot your password? If so, click here. If you haven't registered here before, please contact Rose in the Club office to complete registration" and maybe the account would go into a modded group or something...

Logician 02-18-2003 09:54 AM

* You can create 2 profile fields one for name and the other for sirname. Make sure the profile fields are hidden to user (non editable, admins view only) and note their ids.
* You can edit relevant template and remove username field, instead add 2 form textbox fields for name and sirname (note their name).
* In register.php, find:
PHP Code:

$username trim($username); 

Replace it as:

PHP Code:

if (!trim($name) OR !trim($sirname)) { eval("standarderror(\"".gettemplate("error_fillnamesirnamefields")."\");");}
$username trim($name).' '.trim($sirname); 

(form field names are assumed to be "name" and "sirname"!)

* Create a template named "error_fillnamesirnamefields" and in it ask user to field to name and sirname fields.

* edit template "error_alreadyregistered" ask user to reenter name and sirname fields.

* find:
PHP Code:

$DB_site->query("INSERT INTO userfield $userfieldsnames VALUES ($userid$userfields)"); 

after that add:

PHP Code:

$DB_site->query("INSERT INTO userfield (fieldX, fieldY) VALUES ('.addslashes(htmlspecialchars($name)).','.addslashes(htmlspecialchars($sirname)).' )"); 

(Replace X and Y with the profile id of your name and sirname fields in vb.)

If I didnt miss anything to edit, this should work.. Don't forget to edit relevant templates to remind user that his username = "name sirname".. :)


All times are GMT. The time now is 07:12 AM.

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.01023 seconds
  • Memory Usage 1,734KB
  • 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
  • (4)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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