Advertisement
ikamal7

post status

Mar 14th, 2021
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.40 KB | None | 0 0
  1.  
  2.  
  3. function check_jobs_post( $post ){
  4.     if('jobs' != $post->post_type){
  5.         return false;
  6.     }
  7.  
  8.     // Job Type
  9.  
  10.     $temp           = array();
  11.     $taxs           = isset( $_POST['tax_input']['job-type'] ) ? $_POST['tax_input']['job-type'] : array();
  12.     $taxonomies     = json_encode( $taxs );
  13.    
  14.     $tax_array = json_decode( $taxonomies, true );
  15.     if ( is_array( $tax_array ) ) {
  16.         foreach ( $tax_array as $key => $tax ) {
  17.             if ( count( $tax ) <= 1 ) {
  18.                 array_push( $temp, $tax );
  19.             }
  20.         }
  21.     }
  22.  
  23.     // Insdustry Type array
  24.     $ind_temp       = array();
  25.     $industry       = isset( $_POST['tax_input']['industry'] ) ? $_POST['tax_input']['industry'] : array();
  26.     $industries     = json_encode($industry);
  27.     $ind_array      = json_decode($industries, true);
  28.  
  29.     if(is_array($ind_array)){
  30.         foreach ( $ind_array as $key => $value ){
  31.             if(count($value ) <= 1){
  32.                 array_push( $ind_temp, $value );
  33.             }
  34.         }
  35.     }
  36.  
  37.     // Company
  38.     $company = isset($_POST['company_tax']) ? $_POST['company_tax'] : array();
  39.  
  40.     if ( count( $temp ) > 0 && count( $ind_temp ) > 0 ) {
  41.         $post->post_status = 'draft'; // use any post status
  42.         wp_publish_post($post);
  43.     } else {
  44.         $post->post_status = 'publish'; // use any post status
  45.         wp_update_post( $post );
  46.     }
  47.  
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement