I only want to do bulk action on delete function. I have research so many example on google but still cant make it. Will be so much appreciate if someone be able to help me out on this. Below are my codes. When Select and choose delete on drop down and click apply, nothing is happen.
public function get_bulk_actions(){
$action = array(
"delete" =>"Delete"
);
return $action;
}
public function get_columns(){
$columns = array(
"cb"=>"<input type='checkbox'/>",
"No"=>"No",
"Name"=>"Name",
"Email"=>"Email",
"Unique_Code"=>"Unique Code",
"Created_date"=>"Created Date"
);
return $columns;
}
public function column_cb($item){
return sprintf('<input type="checkbox" name="post[]" value="%s"/>',$item['id'] );
}
public function process_bulk_action() {
// If the delete bulk action is triggered
$action = $this->current_action();
if( 'delete'===$action ) {
$delete_ids = esc_sql( $_POST['post'] );
// loop over the array of record IDs and delete them
foreach ( $delete_ids as $did ) {
global $wpdb;
$wpdb->query($wpdb->prepare( "DELETE FROM mncplugin WHERE id='".$did."'"));
}
wp_redirect( esc_url( add_query_arg() ) );
exit;
}
}