Home › Forums › Front-end Issues › Create Front End Form using Shortcode › Reply To: Create Front End Form using Shortcode
The call to acf_form_head() calls function acf_verify_nonce() that function tests to see if $_POST[‘_acfnonce’] is set. So if there is no form there is two quick function calls. So very little overhead at here. This is the part that has to happen before any HTML output is created.
The real over head is that no matter the results of the above ACF goes through the process or setting up and enqueuing all the needed JavaScript that the form is going to need.
The problem is that where the head function needs to be there wouldn’t be any way to know if it’s going to be needed, especially if you intend to include it it widgets.
If you were only going to include it for use on single posts you could add a field to your post edit page for “Include acf_form_head()” and then before the header is rendered you could do something like
$queried_object = get_queried_object();
if (isset($queried_object->ID)) {
// assumes a true/false field
if (get_field('include_acf_form_head', $queried_object->ID)) {
acf_form_head();
}
}
I can’t think of a single way this could be done with widgets.
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.