Support

Account

Home Forums General Issues ACF frontend form Reply To: ACF frontend form

  • You can only create one post automatically with a front end form, which is the same way that WP works in the back end.

    If I needed to do this I would create and acf/save_post filter that runs after ACF (priority 20) https://www.advancedcustomfields.com/resources/acfsave_post/ In this filter I would get the information from the post that was saved and duplicate it into the other post type. You might want to see if it was already done and if it’s the right post type.

    Here are some basics

    
    add_action('acf/save_post', 'duplicated_acf_form_post');
    function duplicated_acf_form_post($post_id) {
      if (is_admin()) {
       // since this is for a front end form
       // return if we're in the admin
       return;
      }
      if (get_post_type($post_id) != 'your-custom-post-type') {
        // not what you want to duplicate
        return;
      }
      // get post values, or something unique
      // from this post to compare to the other post type posts
      // to see if the duplicate already exists
      // user wp_insert_post() to insert a new post
      // https://developer.wordpress.org/reference/functions/wp_insert_post/
      // or wp_update_post() to update an existing post
      // https://developer.wordpress.org/reference/functions/wp_update_post/
    }