I've read the ACF 'acf/save_post' documentation here: acf-save_postDocs, which states this action enables one to add additional functionally before or after saving/updating a post. I want to test when this action is triggered.
I created a custom post type and a collection of ACF custom fields that are linked to this custom post type.This includes some ACF custom field types that I created using the ACF Starter Kit (see: creating-a-new-field-typeDocs), and they are used for some of the ACF custom fields. When I edit a custom post and then click the 'Update' button in the Gutenberg editor, I expect the 'acf/save_post' action to fire, but it does not seem to do so. Perhaps I am missing something. Here is the relevant code from my theme's 'function.php' file.
function my_acf_save_post($post_id) {
console_log("Testing...");
}
add_action('acf/save_post', 'my_acf_save_post', 20);
function console_log($output, $with_script_tags = true) {
$js_code = 'console.log(' . json_encode($output, JSON_HEX_TAG) . ')';
if($with_script_tags) {
$js_code = '<script>' . $js_code . '</script>';
}
echo $js_code;
}
Citation for the 'console_log' function: Kim Sia (see: https://stackify.com/how-to-log-to-console-in-php/).
I have my web browser's inspector window opened for my custom post type post's editor. After modifying the post and clicking 'Update', nothing displays in the inspector's console pane. I posted about this in the ACF forum but have received no response.
Your feedback is appreciated. Thank you.