Support » Plugin: WP-Members Membership Plugin » How to generate a unique membership ID ?

Viewing 1 replies (of 1 total)
  • Plugin Author Chad Butler


    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.

Viewing 1 replies (of 1 total)
  • The topic ‘How to generate a unique membership ID ?’ is closed to new replies.