Add Account Number

Discussion in 'Integration' started by rmara, Jul 17, 2017.

  1. rmara

    rmara Eager Beaver and Avid Learner

    Joined:
    Jan 21, 2013
    Messages:
    24
    Has anyone created an account number for a new user during the sign up process? Added a field to the user table and like to update it with a generated account number at the time a new user signs up for service. I am digging around, just not sure where the code should be placed. Create a new signup page and add the code there?

    You help is greatly appreciated.

    Roy
  2. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,689
    Hello Roy,

    1. First of all you need to add new SQL field to user profile. You can do it from admin interface at
    aMember CP -> Configuration -> Setup/Configuration -> Add User Fields

    2. Then you can use the following code in site.php to generate this number:
    http://www.amember.com/docs/Site.php_file

    I assume you call this field 'idnum':
    PHP:
    Am_Di::getInstance()->hook->add(Am_Event::USER_BEFORE_INSERT, function(Am_Event $e) {
       
    $e->getUser()->idnum uniqid();
    });
    3. You can add this field to user profile form and within configuration of these field make it readonly:
    aMember CP -> Configuration -> Forms Editor
    field-readonly.png

    4. Also you can use Widget plugin (free) and add this number to user dashboard. Within content of widget you can use
    user specific placeholders ie.:
    HTML:
    <p>Your Account Number: %user.idnum%</p>
    https://www.amember.com/amember/product/widget

    widget.png

    I hope it helps.

    Best Regards

Share This Page