• Hi all,

    I am working on a website that has membership, and you know on WordPress the “user-id” is 1, 2, 3,…
    I want to change it and add a prefix lets say “SA000” and make the “SA” changes depends on the user (Country) when they sign up.
    so its ISO Alph-2, the United States> US, Germany> DE,etc…
    is there any way to do that?

    and if not is there a way to just add prefix to user id only ?

Viewing 1 replies (of 1 total)
  • Hello,

    The ID for a user in WordPress is an integer in the database, so you would not be able to append text to the ID in that column. What I would recommend is to create a user meta field to store a calculated field in. You could then prepend the user’s ID with a country code and save it in the user meta. You could hook into when the user is created and figure out the membership ID based on the country. Then store it like:

    
    $membership_number = $country_prefix . $user_id;
    add_user_meta( $user_id, 'membership_number', $membership_number, true );
    

    I hope this helps give you some ideas on this.

    Sincerely,
    Scott

Viewing 1 replies (of 1 total)
  • The topic ‘change user id and add prefix’ is closed to new replies.