Support

Account

Home Forums Backend Issues (wp-admin) ACF make a post private if there are no rows in a repeater field. Reply To: ACF make a post private if there are no rows in a repeater field.

  •  $ap = get_post_meta($post->ID,'sub_seminars_0_start_date',true);
            $startdate = date("Ymd", strtotime($ap));
            $todaydate = date("Ymd");
          if(strtotime($todaydate) > strtotime($startdate) && !empty($ap)){
           $del_data = array(
                        'Ref' => 'sub_seminars_0_ref',
                        'Start date' => 'sub_seminars_0_start_date',
                        'End Date' => 'sub_seminars_0_end_date',
                        'Venue' => 'sub_seminars_0_venue',
                        'Fees' => 'sub_seminars_0_fees',
                        'CPE Credits' => 'sub_seminars_0_cpe_credits'
            );
          delete_row('sub_seminars', 1);
          
        }
    
        $row = count( get_field('sub_seminars') );
           if ($row == 0) {
                $postid = $post->ID; //Supply post-Id here $post->ID.
                wp_update_post(array(
                'ID'    =>  $postid,
                'post_status'   =>  'draft'
            ));
    
           }

    There seems to be someproblem with my code. Please take a look