Title: Unique users, avoid duplicate names
Last modified: August 21, 2016

---

# Unique users, avoid duplicate names

 *  Resolved [downfast](https://wordpress.org/support/users/downfast/)
 * (@downfast)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/unique-users-avoid-duplicate-names/)
 * Hi Jeff
 * Since there is no registration, how would we handle duplicated authors names?
 * At the moment I have came out with generating a unique random string which goes
   with the name when submitting and asking simple question to users before posting:
 * Is this you first time?
 * Yes => Show the field to write your unique name
 * `<p><input id="nameField" name="nome_unico" placeholder="Write your name" class
   ="form-control input-lg usp-input"></p>`
 * No => Display the field where you write your usual name
 * `<input class="form-control input-lg usp-input" id="userName" name="user-submitted-
   name" type="text" value="" data-required="true" required placeholder="Write your
   username">`
 * Then with jQuery and php I generate the unique string and I set a live preview
   of the name and I tell the user to save it somewhere in order to remember the
   user name generated and use that the next time they post:
 *     ```
       var randomString = "<?php
   
       //set the random id length
       $random_id_length = 10; 
   
       //generate a random id encrypt it and store it in $rnd_id
       $rnd_id = crypt(uniqid(rand(),1)); 
   
       //to remove any slashes that might have come
       $rnd_id = strip_tags(stripslashes($rnd_id)); 
   
       //Removing any . or / and reversing the string
       $rnd_id = str_replace(".","",$rnd_id);
       $rnd_id = strrev(str_replace("/","",$rnd_id)); 
   
       //finally I take the first 10 characters from the $rnd_id
       $rnd_id = substr($rnd_id,0,$random_id_length); 
   
       echo "_$rnd_id" ;
   
       ?>";
   
       $('#nameField').on('keyup', function() {
          var my_value = $(this).val();
          $('#userName').val(my_value + codice);
          $('#userNameMostra').text(my_value + randomString);
       });
   
       });
       ```
   
 * In the jQuery we can see 2 things:
 * 1: The script needed to display the name you are typing + the random string
 * The result would be something like: james_white_3wLCIUWzol
 * 2: I am copying whatever is the genrated unique username to the plugin name field
   so that it will be send with the form.
 * The live preview is just so that he has a place where he can see it live as he
   types and be able to copy it.
 * Using a unique name makes it possible to do: “Show all posts by this author” 
   as explained here: [http://wordpress.org/support/topic/display-subcategories](http://wordpress.org/support/topic/display-subcategories).
 * So this is my solution, am I over complicating it?
    How would you approach or
   what’s your thought in regards of unique author name when they pubblish?
 * Thanks
 * [http://wordpress.org/plugins/user-submitted-posts/](http://wordpress.org/plugins/user-submitted-posts/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [downfast](https://wordpress.org/support/users/downfast/)
 * (@downfast)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/unique-users-avoid-duplicate-names/#post-4131718)
 * Oh well, i’m opting for a registration unfortunatly. The unique name thing is
   far too complex to handle, the solution above is A solution but yet a user could
   copy the generated user name from another post author and use it as its own to
   post, so doesn’t really solve the issue.
 * Unless you have some enlightenment i guess I should simply give up on the non
   registration and just go ahead with a registration approach.
 * Thanks
 *  Plugin Author [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/unique-users-avoid-duplicate-names/#post-4131852)
 * Sounds like a plan, thanks for the feedback.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Unique users, avoid duplicate names’ is closed to new replies.

 * ![](https://ps.w.org/user-submitted-posts/assets/icon-256x256.png?rev=2567685)
 * [User Submitted Posts – Enable Users to Submit Posts from the Front End](https://wordpress.org/plugins/user-submitted-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/user-submitted-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/user-submitted-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/user-submitted-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/user-submitted-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/user-submitted-posts/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/unique-users-avoid-duplicate-names/#post-4131852)
 * Status: resolved