Home Forums Plugin Support WP User Frontend (Free Version) Repeat field and wp insert post

This topic is: not resolved

This topic contains 1 reply, has 2 voices, and was last updated by  Tareq Hasan 5 years, 9 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #9153

    Post count: 28


    I need a hint for saving repeat field values with wp_insert_post. I'm creating two different posts with one form and everything works good with wp_insert_post and wpuf_add_post_after_insert but I'm stucked with the repeat field. Maybe you have some other way around of creating two posts with one form…?



    Tareq Hasan
    Post count: 2831

    For multi-column repeat field, every row saves as a new meta field. Here's the multicolumn code that the plugin uses:
    // save any multicolumn repeatable fields
    foreach ($multi_repeated as $repeat_key => $repeat_value) {
    // first, delete any previous repeatable fields
    delete_post_meta( $post_id, $repeat_key );

    // now add them
    foreach ($repeat_value as $repeat_field) {
    add_post_meta( $post_id, $repeat_key, $repeat_field );

    For single column, it uses a separator (| – pipe) for every field and saves in a single meta key concatenated.

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

The topic ‘Repeat field and wp insert post’ is closed to new replies.