I am having issues implementing a frontend form using ACF Pro.
Currently, when I add acf_form_head();
as described in the ACF Pro documentation to my template. It gives me this error -
Warning: Cannot modify header information - headers already sent by (output started at /base.php:9) in /wp/wp-includes/pluggable.php on line 1207
The post is actually created, but it shows that error instead of redirecting to the new post.
I tried putting acf_form_head();
in the base.php file before get_template_part('templates/head');
That still gave me the same headers already sent by
error.
Then I tried putting it in the functions.php file like this
add_action( 'init', 'brandpage_form_head' );
function brandpage_form_head(){
acf_form_head();
}
This no longer gives me the headers already sent by
error, but instead it creates duplicate posts.
I’ve tried putting that acf_form_head(); function in header.php, head.php and in the footer, but nothing has worked yet.
Does anyone know where I should put this function in my Sage/Bedrock set up?
I appreciate the help!
1 Like
Pretty sure you are not using namespaces with your action:
Foxaii
3
This should work fine putting the function in base.php
and I don’t think that it’s a namespace issue.
Make sure the function is added before the <!doctype html>
and remove any whitespace that is outside the <?php
and ?>
tags.
1 Like
Hi all,
I get a
Fatal error: Call to undefined function Roots\Sage\Extras\acf_register_form() in /var/www/public/wp-content/themes/okisam/lib/extras.php on line 566
but just in localhost and domain.dev. But in production works perfect. I got same code in development and production.
Removing function from lib/extras.php in development then I get:
Fatal error: Call to undefined function acf_form_head() in /var/www/public/wp-content/themes/okisam/base.php on line 7
from acf_form_head() in base.php, after following @Foxaii indications.
Same story here. Works fine in production.
Pretty weird. Any ideas what could it be related?
Thanks in advance for any suggestions.