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!
💻 The next ACF Chat Fridays features a live demo of one of our most highly-requested features: registering CPTs and custom taxonomies directly in ACF. Don’t miss it!— Advanced Custom Fields (@wp_acf) February 27, 2023
📆 Friday 3rd March 3pm UTC
👉 Register here - https://t.co/3UtvQbDwNm pic.twitter.com/j4r4ouQtz9
© 2023 Advanced Custom Fields.