Ready to get started?Download WordPress


[resolved] How to generate a unique membership ID ? (2 posts)

  1. laxer
    Posted 10 months ago #

    Hi, I would like to enquire how to generate a unique membership ID upon successful registration ?

    Any hooks to use ? or must edit the core files ?
    Need to add sequence to the database table ?


  2. Chad Butler
    Plugin Author

    Posted 10 months ago #

    I guess the answer depends on what you want it to look like. WordPress already creates a unique ID as the primary key in the wp_users db table. This is $user_ID.

    If you want some type of a string, then you need to write some type of function to create it. I'd probably base that on a combination of the ID + something generated off the username or email (both of which are validated as unique during registration).

    If you use the user ID, then you would hook into the wpmem_post_register_data action. This action comes after the user has been successfully registered. The hook has access to all fields of the user's registration data including the ID. See the hook documentation here.

    If you wanted to do something before the user data is inserted, you could use wpmem_pre_register_data which is the same type of action, but it doesn't have the user's $user_ID because that has not been generated.


You must log in to post.

About this Plugin

About this Topic


No tags yet.