What is the fastest way to generate a unique id number when registering a user

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).

Leave a Comment