• Resolved dbecker88

    (@dbecker88)


    I believe this started with WP ver. >4.4
    Events Manager is version: 5.6.6.1

    Here is code used to create event:

    $EM_Event = new EM_Event();			
    $EM_Event->event_name = $evt_name;
    $EM_Event->event_start_date = $evt_start_d;
    $EM_Event->event_start_time = date("H:i:s",strtotime($evt_start_t));
    $EM_Event->event_end_date = $evt_end_d;
    $EM_Event->event_end_time = date("H:i:s",strtotime($evt_end_t));
    $EM_Event->start = strtotime($EM_Event->event_start_date." ".$evt_start_t);
    $EM_Event->end = strtotime($EM_Event->event_end_date." ".$evt_end_t);
    $EM_Event->event_all_day = 0;
    $EM_Event->save(); //save the event
    

    WP debug error

    WordPress database error Column 'post_content' cannot be null for query INSERT INTOwp_posts(post_author,post_date,post_date_gmt,post_content,post_content_filtered,post_title,post_excerpt,post_status,post_type,comment_status,ping_status,post_password,post_name,to_ping,pinged,post_modified,post_modified_gmt,post_parent,menu_order,post_mime_type,guid) VALUES (1, '2016-09-07 07:49:16', '2016-09-07 14:49:16', NULL,......

    This never used to be a problem, anyone have a workaround?

    thanks.

    • This topic was modified 9 years, 8 months ago by dbecker88.
Viewing 1 replies (of 1 total)
  • Thread Starter dbecker88

    (@dbecker88)

    I’m guessing that starting with ~4.4 WP required a value for post_content and doesn’t consider NULL as acceptable?

    My workaround is to filter the wp_insert_post content and replace NULL with ”
    This is confirmed working.

    
    function overRide_EM_Null_Post($data , $postarr){
    	if(is_null($data['post_content']) && $data['post_type']=='event'){
    		$data['post_content']='';
    	}
    	return $data;
    }
    add_filter( 'wp_insert_post_data', 'overRide_EM_Null_Post', 99, 2 );
    
Viewing 1 replies (of 1 total)

The topic ‘EM_Event->save() causes ERROR’ is closed to new replies.