Abhi324's avatar

Unique Nickname during registration (automatically - no user input)

Hello ,

I need some help with a small issue . When i create a user , i am also creating his profile at the same time and setting his nickname..

The nickname is a combination of the first and last name . However i need the nickname to be unique .

Since this is done automatically at registration , i can't ask the user to change it .

basically Nick = firstname.lastname

During the registration process - i want to check the database to make sure there is no other nickname like this else add a number at the end e.g : firstname.lastname.3

is there any way to do that ?

0 likes
2 replies
zachleigh's avatar

Use ajax. Simply send the first and last name to your server side code and have a method that queries the database for the nickname. If the nickname exists, on the server, find the next available numbered nickname. Return the nickname to the client side.

fredricrhoads's avatar

@zachleigh A simple way to ensure the nickname remains unique during automatic registration is to first generate the base nickname using firstname.lastname, then query the database to check whether it already exists. If it does, count or retrieve existing similar nicknames and append the next available number, such as firstname.lastname.1, firstname.lastname.2, and so on, until a unique value is found before saving the profile. This keeps the process automatic without requiring user input and avoids duplicate records. By the way, while exploring developer solutions and community forums.... www.rbtv77plus.app

Please or to participate in this conversation.