I’m quite confused as to why this isn’t working. I’ve tried a few different options, but everything online is too generic for me to really grasp it.
What I’m trying to do is pretty straightforward. Do I need to build the form and then reference the data input and “save” the form to the ACF API or does it render the form for me?
<?php
acf_form_head();
function my_pre_save_post( $post_id ) {
// check if this is to be a new post
if( $post_id != 'new' ) return $post_id;
// Create a new post
$post = array(
'post_status' => 'publish' ,
'post_title' => 'title' ,
'post_type' => 'job' ,
'field_groups' => array($_POST["fields"]['field_533f68b959002'], $_POST["fields"]['field_533f68128af07'], $_POST["fields"]['field_533f684f810ab']),
);
$post_id = wp_insert_post( $post );
do_action('acf/save_post', $post_id);
return $post_id;
}
add_filter('acf/pre_save_post' , 'my_pre_save_post' );
get_header();
?>
<div id="primary">
<article class="white_bg">
<h2>Post Job: Futura</h2>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php
$args = array(
'post_id' => 'new',
'post_type' => 'job',
'field_groups' => array($_POST["fields"]['field_533f68b959002'], $_POST["fields"]['field_533f68128af07'], $_POST["fields"]['field_533f684f810ab']),
);
acf_form( $args );
/*
$options = array(
'post_id' => 'new_post',
'new_post' => array(
'post_type' => 'job',
'post_status' => 'publish'
),
'field_groups' => array('field_533f68b959002', 'field_533f68128af07', 'field_533f684f810ab'), // this will find the field groups for this post (post ID's of the acf post objects)
'form' => true, // set this to false to prevent the <form> tag from being created
'form_attributes' => array( // attributes will be added to the form element
'id' => 'post',
'class' => '',
'action' => '',
'method' => 'post',
),
'return' => add_query_arg( 'updated', 'true', get_permalink() ), // return url
'html_before_fields' => '', // html inside form before fields
'html_after_fields' => '', // html inside form after fields
'submit_value' => 'Post New Job', // value for submit field
'updated_message' => 'Your opening has been posted!', // default updated message. Can be false to show no message
);*/
?>
<?php endwhile; ?>
<?php endif; ?>
</article><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>