According to the WordPress codex save_post_{$post->post_type} should pass three arguments:
do_action( "save_post_{$post->post_type}", int $post_ID, WP_Post $post, bool $update )
Here is my code:
add_action( 'save_post_guide', array($this, 'saveGuideMeta') );
function saveGuideMeta(int $post_ID, WP_Post $post, bool $update) {
if (isset($_POST['guide_keyword'])) {
update_post_meta($post_ID, 'guide_keyword', sanitize_text_field($_POST['guide_keyword']));
}
}
I literally copied the function signature to be sure, but it throws an ArgumentCountError when I save the post (so I know the function is being called and the hook is "working").
The Exception
Fatal error: Uncaught ArgumentCountError: Too few arguments to function saveGuideMeta(), 1 passed in public_html/wp-includes/class-wp-hook.php on line 288 and exactly 3 expected
It's as if the save_post_guide hook is not passing the three arguments, only one.
I am simply attempting to update post meta when a post is saved. What am I doing wrong here?