Jump to content

auto generate number for client custom field


Recommended Posts

Dear Members

hope all are still safe. Can some one help me make a hook which will generate a 8 digit random number for the custom client field.

so what will be happen when customer register in our website the hook will add automatically a 8 digit number in the custom client field. the field name will be Account Number.

the number will be unique in the database for each client.

 

hope i able to explain the thing

 

Kind Regards

Mahim

Link to comment
Share on other sites

I am trying to think how to apply it but if it is a randomly generated number through code when it gets to the database it might not end up unique as you requested.

What I would do is create a custom field like you normally would then find that field in the database and change its structure to auto increment then do some limitation on that field to prevent the user from modifying it. So that it is a read only field.

Link to comment
Share on other sites

1 hour ago, weelow said:

I am trying to think how to apply it but if it is a randomly generated number through code when it gets to the database it might not end up unique as you requested.

What I would do is create a custom field like you normally would then find that field in the database and change its structure to auto increment then do some limitation on that field to prevent the user from modifying it. So that it is a read only field.

thanks but hook can check in database for existing number... so thats how its became unique

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated