Home Forums ACF PRO Random code field for coupons system Reply To: Random code field for coupons system

  • @shonlevi

    Hmmm… this could be tricky.

    First… have a peek through this thread here.

    You will see that.. in order to pre-populate a repeater, the rows will have to exist ahead of time.

    What if…

    1) You had a ‘codename’ text field.
    2) You had a ‘howmany’ number field (to decide how many codes to generate).
    3) You had a textarea field to store your coupons…
    … you could store them one per line (and just ‘append’ them when you add more), and then separate the data with a “pipe” | symbol to deal with later. You can use the PHP explode() function to split the data by the “pipe” symbol.


    Codename: EXAMPLE
    Howmany: 3
    Generated Coupons:


    Here’s a page that describes how to extract each line from a textarea field. Then, of course, use ‘explode’ to separate the data from each line.

    Hope that helps. There may be a better way, it’s just not coming to me if so 🙂