Assigning members unique numbers

Discussion in 'Templates customization' started by gregmarzano, May 21, 2013.

  1. gregmarzano

    gregmarzano New Member

    Joined:
    May 20, 2013
    Messages:
    3
    Hi- I'm creating a site where each member gets assigned a unique id number upon registration, which is displayed in their profile and is sent to them as placeholder text in an email. So far I've tried putting a random number generator on the page to spit out a number, but this isn't recognised by aMember and recorded, and I've put a box underneath the random number generator to enter the number (though of course the user could enter anything), and although this appears in the user's profile it can't be added as a placeholder to the registration e-mail.

    Any ideas?
  2. gregmarzano

    gregmarzano New Member

    Joined:
    May 20, 2013
    Messages:
    3
    Hi- I've had a bit more of a look in to the functionality, and it looks like there is a way to do this, but there are still problems:

    Each user has a user id, but this is (currently) a single digit. For our own admin purposes we need the number to be six digits, and ideally a random, non-repeating number (so the first member isn't 000001). I know this must be buried in the php somewhere, so does anyone know where I can start looking?
  3. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    Creating a random digit shouldnt be a problem, but to make it non-repeating you'd need to check the database to make sure it hasnt been used before. Even using a timestamp could be a problem if you get 2 orders in at exactly the same second.

    David
  4. thehpmc

    thehpmc Member

    Joined:
    Aug 24, 2006
    Messages:
    901
    Why not use timestamp multiplied by a random number?

    Chances of an identical random number at the same instant, even is the timestamp for two signups is the same, would be so remote that checking in database would not be necessary.
  5. gregmarzano

    gregmarzano New Member

    Joined:
    May 20, 2013
    Messages:
    3
    Hi - the timestamp idea should work- I highly doubt there's ever going to be two people signing up at the exact same second. From the look of the timestamps that are on the membership info already the format is: 2013-05-21 11:34:25. Would it be possible for aMember to record the day, minute and second as a six digit number (ie 213425) and then be able to put this number in signup e-mails as a placeholder (ie 'your membership number is 213425)?
  6. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    Sure, seems doable, maybe s some custom code in site.php.

    David
  7. drgcmembership

    drgcmembership aMember Pro Customer

    Joined:
    Mar 7, 2014
    Messages:
    2
    a better idea is to set a new members user_id number(in the db) to a large number like 200000 and then members added after this will automatically increment above that number. this is what amember does already (i think it does a list-last to find the next number when adding the next user). the the next added new users will be auto-numbered with a user_id of 200001.

Share This Page