Home Forums ACF PRO Problem retrieving fields using save_post


Problem retrieving fields using save_post

  • Love the plugin, but I’m having an issue retrieving a field using the save_post functionality.

    What I’m attempting to do is grab a field from a front-end form when it gets submitted and save it as a variable for post_title. This forum post seemed to be the answer to my problem but for some reason I can’t get it to work:

    Here’s the code I’m using:

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

    I feel like there’s probably something really simple I’m overlooking. Thanks in advance for any help.

  • Hi @nhall

    Thanks for the code. I’ve just tested it and can confirm that it works.
    Can you please debug your function to double check that the value is being found?

    echo '<pre>';
    echo '</pre>';
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Problem retrieving fields using save_post’ is closed to new replies.