Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter lunari

    (@lunari)

    This is brilliant. Had no idea. Thank you!

    It is a metabox old way. I’m into Gutenberg so will convert it later but need to up skill first a bit.

    So inside the filter I check if isset($_POST[‘tax_input’]) and run the code posted above else I grab taxonomies from DB and set $data therefore save_post is clear of that code. Thank you.

    Thread Starter lunari

    (@lunari)

    “wp_insert_post_data” filter works great on Quick Edit. I get taxonomies from the $_POST and set the post status in the filter. But when I am on the full edit page I have no access to taxonomies as $_POST contains now different data than $_POST from Quick Edit inside the filter. Is that normal? How can I access taxonomies on edit post inside that filer?

    function filter_handler( $data , $postarr ) {
            $temp = array();
            $taxonomies =  json_encode($_POST['tax_input']);
            $tax_arr = json_decode($taxonomies,true);
    
            foreach ($tax_arr as $key => $val){
                if(count($val) <= 1){
                    array_push($temp, $val);
                }
            }
    
            if(count($temp) > 0 ){
                $data['post_status'] = 'draft';
            }
            else {
                $data['post_status'] = 'publish';
            }
          
            return $data;
        }
Viewing 2 replies - 1 through 2 (of 2 total)