Home Forums ACF PRO Front end form with repeater field


Front end form with repeater field

  • I’m looking to create a front end ‘event reminder’ form which consists of only 1 input field – email address and a ‘remind me’ button. This form will be inserted into the woocommerce single product page.

    When users enter their email address and click the ‘remind me’ button, their email address will be stored in the backend of the product page, in the custom field which I’ve created. I managed to achieve this by creating a regular text field and then implementing the acf_form() function to display that field. The email addresses get saved to the backend as well.

    But since it’s only a single text field, all previous email addresses get overwritten when someone submits a new value. Should I use a repeater field instead of a single text field and then implement the add_row function so that the backend will be able to store all the email addresses?

  • I don’t think this is the best place to store email addresses like this.

    Why not use acf/save_post and then add it to the wp_options table as an array ?

  • I think @beee has good idea. Depending on what you’re going to use it for and how I’d probably make it a multidimensional array and store all the emails for all the posts in one value. Another options would be to save the “post” that the user has subscribed to as an array to the user meta table, assuming that they registered users of some type. Again, it depends on how your going to use the values.

  • @John Huebner actually @beee has a bad idea, it’s a better one, definitely do-able, but some thing are design-wrong there – you would need to fetch all the data, even if you are trying to add just a single email address.

    It is a quick solution, if you have a low rate emails/product (and you know it will ever be so – which you probably don’t and can’t know).

    acf/save_post is a good start, but I think you should store it to product/post meta table – one row per 1 email – they can have same key…

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Front end form with repeater field’ is closed to new replies.