• Hi Guys,

    Is there a way the I can auto set a post to draft if a number of terms are not met. For example:

      if the post title contains the text ‘https://’ the post will be disabled.
      if the price of the product goes over a certain amount.

    The reason I want to do this is that I am importing products and sometimes the import goes wonky if the feed is showing incorrect data.

    Thanks!

Viewing 1 replies (of 1 total)
  • Hello kchegwin,

    Please use the following code:

    add_filter( 'wp_insert_post_data', 'set_post_to_draft', 99, 2 );
    
    function set_post_to_draft( $data, $postarr ) {
    
      if ( your_condition ) {
        $data['post_status'] = 'draft';
      }
    
      return $data;
    }

    Thanks

Viewing 1 replies (of 1 total)
  • The topic ‘Auto moderate posts’ is closed to new replies.