WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a client who wants to register users and give them a unique ID number when they complete registration. (Kind of a member number sort of thing)

Can I just setup the WP member table to start id numbers in the high 10 digit range?

User experience would be:

  1. user would visit the site
  2. user would register
  3. WP would issue an 10 digit id number
share|improve this question
I'd personally just produce the Unique ID on the fly, based on the user's ID(like Peter suggested at the start of his answer), or second to that i'd use Jan's approach. Jan and Peter +1..! :) – t31os Feb 10 '11 at 14:09
up vote 2 down vote accepted

The ID column of the users table is AUTO_INCREMENT, so you can set the base counter to a high number:

ALTER TABLE wp_users AUTO_INCREMENT = 1000000000;

All new users will have an ID that is higher than this value. Calling this operation is safe, if you accidentally set it to a low number either nothing happens (in a InnoDB table), or it is set to the highest existing number + 1 (in a MyISAM table).

share|improve this answer

The ID field will definitely work. If you wanted a larger number you could just add 10,000 to it and it will still be unique.

Other ways of doing this get more involved. You can store a value in the wp_options table, and then fetch, increment, save, but you have a small window of opportunity where two people could end up with the same number, so you need to check for that and repeat if there was a collision. You can generate MD5 (or SHA1) hashes from some chosen bits of user info, but this will give you a big, nasty string of characters. This can be useful when generating a UUID (Universally Unique ID) across multiple systems because the chance of collision is vanishingly small.

share|improve this answer

I guess also easy would be to hook into the registration process (pre data get's submitted to DB) and just change the user_registered column from wp_usermeta table with some preg_replace for empty spaces. They would be unique as long as you're not submitting them in the exact same second. The value won't ever be changed by anyhting after the registration process + it would allow ordering by registration time if you may need that.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.