Support

Account

Home Forums Front-end Issues frontend creating post with acf Reply To: frontend creating post with acf

  • There are a few things that are going on in the code above, which may be the way you’ve copy/pasted it, but are worth noting.

    Firstly – some programs style apostrophes as a slightly different type of character that looks a lot like an apostrophe but is more akin to a grave, or an acute accent. MS Word is killer for this, but a lot of other programs do it too and it looks like something similar is happening in your code.

    – If we fix this, we can then see a couple of other issues – on line 6, you don’t close your php tag before the <h1>.

    – Your HTML comment is also missing a hyphen, as comments should be <!– –>, however this won’t cause anything other than styling issues for you.

    – The parameter “field_groups” has been misspelled as “field_gruops” which may be the underlying cause of your error.

    – The updated message has some curly quotes in it as well.

    Fixing all of the above gives you some code that looks more like the following:

    <?php $my_fields = array(
    'field_57065cfb19c17',
    'field_57065dc319c18',
    'field_57065e1a19c19',
    'field_57065ea919c1a'
    );
    ?>
    <h1><?php the_title(); ?></h1>
    
    <?php the_content(); ?>
    
    <!-- <p>My custom field: <?php //the_field($provider_name); ?></p> -->
    
    <?php $new_provider = array (
    'post_id'	=> 'new_post',
    'new_post' => array(
    'post_type' => 'provider',
    'post-status' => 'draft'
    ),
    'field_groups'	=> $my_fields,
    'form' => true,
    'return' => '/',
    'html_before_fields' => ”,
    'html_after_fields' => ”,
    'submit_value'	=> __('Create a new provider'),
    'updated_message' => __("The provider has been saved", 'acf')
    
    );
    
    acf_form($new_provider);
    ?>

    If you run that through, it may work a little better?