Support

Account

Forum Replies Created

  • Nope. Never figured it out. Went a different route using a different plugin.

  • Sorry @robnero. It’s early, I have a newborn that doesn’t sleep, and I’m only on coffee #1. Of course those are placeholders…

    No, even using the long field names, no success getting post_title or post_content to populate via $_POST variable via the acf_form function.

    I guess I could set ‘post_title’ to true in the acf_form, hide the form field via CSS/JS, have it populate from another field via JS, and then be submitted that way. Just seems like a lot of extra work to do something that should be able to be accomplished on the server side.

  • @robnero Nope. I tried that too, but I don’t think the $_POST variables have been established before the form submits. So they can’t be passed to acf_form_head before they exist. I may be wrong on why, but it didn’t work in testing.

    As an aside, using ‘field_1’, ‘field_2’, etc. Doesn’t work at all. At least not filtering with pre_save_post or update_content_value. I’ve only had success with the nonsense-looking field names I pull off of the source code HTML that looks like ‘field_5419e384411cb’ or something similar.

  • @rockeypjb and @robnero

    That’s not working with PRO. I set up the front end form like this:

    acf_form( array('post_id' => 'new_post',
      'new_post' => array( 
        'post_title' => 'Temp Title',
        'post_content' => 'Temp Contents',
        'post_type' => 'members', 
        'post_status' => 'publish' ),
      'submit_value' => 'Submit',
      'field_groups' => array( 17 ),
      'return' => get_the_permalink() ) );

    I tried it without the ‘new_post’ array, knowing that’d I’d be changing the values in a pre_save_post filter, but the post wouldn’t save without it.

    Then the pre_save_post function is:

    if( $post_id == 'new_post' )
    {
      $post = array( 'post_title' => $_POST['acf']['field_2'],
        'post_content' => $_POST['acf']['field_2'],
        'post_type' => 'members', 
        'post_status' => 'publish' );
    
      $post_id = wp_insert_post( $post );
    }
    
    return $post_id;

    None of the changes made via the pre_save_post function had any effect on the post that was saved to WP.

  • Just messing around here. I ran this to see where the Post Title and Post Content are getting passed.

    add_filter('acf/pre_save_post' , 'cca_pre_save_post', 10, 1 );
    function cca_pre_save_post( $post_id )
    {
       $_POST['acf']['field_5419e3b4411cc'] = print_r( $_POST, true ); // textarea in form
       return $post_id;
    }

    And this was returned:

    Array
    (
        [_acfnonce] => 
        [_acfchanged] => 1
        [acf] => Array
            (
                [field_5419e384411cb] => The Business Name
                [field_5419e3b4411cc] => 
                [field_5419de9b4834f] => The Buisiness name
                [field_5419deb048350] => 
                [field_5419df0348353] => 
                [field_5419dee748352] => 
                [field_5419e441411ce] => 
                [field_5419e457411cf] => 
                [field_5419e47e411d0] => 
                [field_5419e4bb411d1] => 
                [field_5419e4c8411d2] => 
                [field_5419e4eb411d3] => 
                [field_5419e520411d4] => 
                [field_54258b963546b] => 
                [field_542490cc4e78f] => 
                [field_54258cb962f62] => 
                [field_5425c8a5fbebe] => 1
            )
    
    )
    

    Which, as you can see, doesn’t include either the Post Title or Post Content. However, looking at the Form Data in Dev Tools in Chrome, this is what’s getting passed:

    acf[_post_title]:The Post Title
    acf[_post_content]:
    acf[field_5419e384411cb]:The Business Name
    acf[field_5419e3b4411cc]:
    acf[field_5419de9b4834f]:The Buisiness name
    acf[field_5419deb048350]:
    acf[field_5419df0348353]:
    acf[field_5419dee748352]:
    acf[field_5419e441411ce]:
    acf[field_5419e457411cf]:
    acf[field_5419e47e411d0]:
    acf[field_5419e4bb411d1]:
    acf[field_5419e4c8411d2]:
    acf[field_5419e4eb411d3]:
    acf[field_5419e520411d4]:
    acf[field_54258b963546b]:
    acf[field_542490cc4e78f]:
    acf[field_54258cb962f62]:
    acf[field_5425c8a5fbebe]:1

    So … where does ‘_post_title’ go?

  • Bump. Same thing here.

    I’ve tried filtering the post title using the acf/update_value filter. But no combination of _post_title, acf-_post_title, post_title, etc. used as key= or name= seems to fire the filter.

    add_filter('acf/update_value/name=_post_title', 'cca_acf_update_post_title', 10, 3);
    function cca_acf_update_post_title( $value, $post_id, $field  )
    {
    	return "name=_post_title";
    }

    That does nothing.

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