Hello, I’m trying to use ACF PRO’s acf.add_action function for form submission purposes but I keep getting acf is not defined. Anybody having the same issue?
You need to make sure that ACF JS files are loaded before your files or that you wait until they are loaded before attempting to reference them.
How are you using it?
Sorry I’m not really a pro programmer. How do I make sure the ACF JS Files are loaded?
It depends on where you’re adding code.
If you are enqueuing a JS file then you need to set the $deps
argument to array('acf-input')
and you should also enqueue scripts on the acf/enqueue_scripts
hook for any scripts you’re adding for ACF.
If you are putting code into the page the something like this usually works
(function($){
// your code here
}(jQuery)
More information here https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/