Forum Academy Marketplace Showcase Pricing Features

How to create unique usernames?

Once the user signs up in my app he is required to pick a username. Now I want to ensure that the username should not be duplicated in my database. i.e. If a user has already selected a username then that username should not be selected by someone else.
How should I go about this?

2 Likes

In a workflow:

“Only when” a search for that exact username = count:0

After “Username =” you will want to reference the input field for username that your user is submitting.

2 Likes

You may also want to match the search query by trimming the input field, and make sure to trim usernames before saving to the database.

From reference:

:trimmed
Removes the spaces at the beginning or the end of the text: ’ fd ’ -> ‘fd’.

1 Like

Umm. Did not get this one.

As of now this is my workflow. When the user clicks on the button this is what takes place. How should I go from here. I want to provide an error is the username already exsits otherwise create the username

You need to create an “Only when” condition on your workflow event, similar to the screenshot I shared. You need to prevent the workflow from firing if the username exists. You then create another event that fires when the username DOES exist and then you can specify an error message to display.