Home > AI > Backend > Wordpress >

how to debug in the save_post

Example:

add_action( 'save_post', 'st_mb_save' );
        function st_mb_save() {
            global $post;
            
            if (define(DOING_AUTOSAVE) && DOING_AUTOSAVE) {
                return $post->ID;
            }
            
            // these two lines
            print_r($_POST);
            $tmp = fopen(dirname(__file__).'/my_logs.txt', "a+"); fwrite($tmp,"\r\n\r\n".ob_get_contents());fclose($tmp);
            
            update_post_meta($post->ID, 'st_mb_latex_field', $_POST['st_mb_latex_field']);
        }

Leave a Reply