Support

Account

Home Forums General Issues How to show custom field inputs on acf_form() front end when creating new post

Solving

How to show custom field inputs on acf_form() front end when creating new post

  • Hi. First off I would like to say well done on an awesome plugin. One thing I am not clear on though.

    When following your guide on how to create posts from the front end, the form only has the title and content fields. How can we show the custom fields we have set for that post type (since this would make more sense)?

  • Hi ch1n3s3b0y

    In its front page you should put something like:

    <?php
    acf_form(array(
    'post_id'		=> 'new_post_emp',
    'field_groups'	=> array( 86 ),
    'return' => add_query_arg( 'updated', 'true',   "http://qgbrain.com.br/web/assesstment/pesquisar-empresa/" ),
    ));
    ?>

    In the function.php you should put:

    <?php
    add_filter('acf/pre_save_post' , 'my_pre_save_post' );
    function my_pre_save_post( $post_id ) {
    
    if( $post_id == 'new_post_emp' ) {
    
    // data send by POST in form
    $title = $_POST['fields']['field_552b299a1844c'];
    
    // Default data post
    $post = array(
    'post_status'	=> 'Publish',
    'post_type'		=> 'processos',
    'post_title'	=> '0000 |'.$title,
    );	
    // action for update
    $post_id = wp_insert_post( $post ); 
    
    }	
    }
    ?>

    this way the created form is available on your front-end

    I hope it helped

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

The topic ‘How to show custom field inputs on acf_form() front end when creating new post’ is closed to new replies.