Support

Account

Home Forums ACF PRO problem to configure advanced custom field

Solving

problem to configure advanced custom field

  • Hello everyone
    I would like to create a cooking recipe form that sends the information after submission in a recipe post type

    So I have a form so that the user can enter their data
    Who is next

    	<?php /*Template Name: User Submit*/; ?>
    <?php acf_form_head(); ?>
    <?php get_header(); ?>
     
        <div id="container" >
     
        <div class="row">
            <div class="col-sm-12">
     
                <?php /* The loop */ ?>
                <?php while (have_posts()):
        the_post(); ?>
     
                    <!-- a supprimer si on enlève l'éditeur par défaut -->
     
                    <!------------>
     
                        <p> <?php the_field('Ingredients'); ?></p>
                        <p> <?php the_field('Cuisson'); ?></p>
                        <p> <?php the_field('Temps'); ?></p>
                    <p> <?php the_field('Preparation'); ?></p>
                    <p> <?php the_field('Difficulté'); ?></p>
     
                    <?php $options = array(
            'post_id' => 'new',
            'field_groups' => array(
                4
            ) ,
            'post_title' => true,
     
            'post_type' => 'recette',
            'post_status' => 'draft',
     
            //'updated_message'    => 'Merci pour votre participation!Votre recette sera publiée prochainement',
            'updated_message' => __("Recette publiée", 'acf') ,
            'submit_value' => 'Postez votre recette'
        );
        acf_form($options); ?>
     
                <?php
    endwhile; ?>
    </div>
            </div><!-- #content -->
        </div><!-- #primary -->
     
    <?php get_footer(); ?>

    I created a recipe CPT
    And a single.php file to display the result

    the problem is that the articles created will be added in article and not in recipe

  • You need to set the ‘new_post’ argument for acf_form(), not ‘post_type’ and ‘post_status’. The value of this argument is an array of values.

    
    ....
    'new_post' => array(
      'post_type' => 'recette',
      'post_statues' => 'draft'
    ),
    ......
    
  • thank you for the answer
    but this is at the level of the function file

  • No, I was talking about your options for calling acf_form(). Yours are wrong.

    
    $options = array(
      'post_id' => 'new',
      'field_groups' => array(
        4
      ),
      'post_title' => true,
      'new_post' => array(
        'post_type' => 'recette',
        'post_status' => 'draft',
      ),
      'updated_message' => __("Recette publiée", 'acf'),
      'submit_value' => 'Postez votre recette'
    );
    acf_form($options);
    
  • ah okay, a big thank you for the code and the correction

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

You must be logged in to reply to this topic.