Home › Forums › ACF PRO › Random code field for coupons system › Reply To: Random code field for coupons system
I have website, and posts, in every post I have text field which called “codename” and repeater field which called “coupons” – it have 3 sub-fields – name, description, code
For example – I create post, and fill in “EXAMPLE” in the “codename”
Then I want to create coupons. what I want the system to do is –
Everytime I’ll click on “add row” I’ll get a new row in the repeater (default behavior), BUT I want the sub-field “code” to get value automatically “EXAMPLE-764” or “EXAMPLE-421” etc…
I should take automatically the field codename and add to it a 3 digits random number
To make random number – I know.
I just need to know:
1. how to run function when admin click “add row”
2. how to get the value in other field (before it published…)
3. how to update the subfield value in the add post page (and not in database, after the post was published, like “update_field” function does)
Hope it is more understandable now
Thanks for helping 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.