Advanced Custom Fields form and post_title

This is regarding the Advanced Custom Fields plugin for WordPress.

I’m trying grab a field from a front-end form when it gets submitted and save it as a variable to set the post_title. This post seemed to be pointing in the right direction but I couldn’t get it to work: http://support.advancedcustomfields.com/forums/topic/need-help-with-save_post-hook/

Read More

This is the code that I’m using:

   <?php 
      add_action('acf/save_post', 'retrieveEventName', 20);
    function retrieveEventName( $post_id )
    {
    $eventName = get_field('name_of_event', $post_id);
    }
   ?>
   <?php
    $args = array(
       'post_title'     => $eventName,
       'post_type'      => 'post',
       'post_status'    => 'draft',
       'post_category'  => array(9),
       'comment_status' => 'closed'
       );
       acf_form(array(
          'post_id'      => 'new_post',
          'form'         => true,
          'new_post'     => $args,
          'submit_value' => 'Create a new event'
    ));
    ?>

Thanks for any help!

Related posts

Leave a Reply