Woohoo!
Thanks to your pointer, I found out that the theme I use as a boilerplate was probably causing the mess with the big scary error I got.
I have also done some more testing and I just discovered that the original problem I posted (which was: all of a sudden I can’t use autocomplete anymore on the post form), was caused by loading the javascript to the google maps api like this, in the footer:
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false">
I was loading the api in my theme’s footer.php file, and I have moved it to the actual page where I was using it. Problem solved!
If you have a moment I wouldn’t mind a brief explanation why this is, as I’d love to be educated a bit more.
Thanks for all the help!
Hi Elliot,
thanks for your prompt reply!
I retraced my steps on a clean (local) install; same problem.
I retraced my steps on a test wordpress site, and things worked as I wanted.
I then tried to retrace all the steps I took to create a form on my live site (in maintenance mode, it’s a bit of a mess) but now I get the following error when I submit a form from the front end:
Warning: Cannot modify header information – headers already sent by (output started at /THEMENAME/page-full-width.php:8) in wp-includes/pluggable.php on line 899
page-full-width.php is the template where I call the acf_form_head, and the form. So basically just:
<?php
acf_form_head();
get_header();
?>
and after some html markup
<?php
$options = array( 'post_id' => 'new', 'field_groups' => array( 31 ),
);
if (is_user_logged_in()) {
acf_form( $options );
}
?>
I don’t think the above code is incorrect?
In the functions.php I have the following:
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' => 'draft' ,
'post_title' => $_POST["fields"]['field_528a8d1ae2674'],
'post_type' => 'custom_type',
'post_content' => $_POST["fields"]['field_528a8d1fe2675']
);
// insert the post
$post_id = wp_insert_post( $post );
// update $_POST['return']
$_POST['return'] = add_query_arg( array('post_id' => $post_id), $_POST['return'] );
// return the new ID
return $post_id;
}
add_filter('acf/pre_save_post' , 'my_pre_save_post' );
add_action( 'wp_print_styles', 'my_deregister_styles', 100 );
function my_deregister_styles() {
wp_deregister_style( 'wp-admin' );
}
The only fields I have set up in ACF to be used in the front-end form are title, content, and a map.
Hope this helps! I will keep on tryin’ 😉
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.