Support

Account

Home Forums Bug Reports Google Map field / autocomplete error through frontend Reply To: Google Map field / autocomplete error through frontend

  • 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’ 😉