At this moment i am trying to modify this plugin that deletes table rows to delete ONLY rows that don't contain the word "Cekanje" in the column "Status", this is the code and the solution i am trying to build, if anyone can help me:
$tableId = (int)$_POST['table_id'];
$idKey = sanitize_text_field($_POST['id_key']);
$idVal = (int)$_POST['id_val'];
$wpdb->delete($mySqlTableName, array($idKey => $idVal));
$columnsMeta = WDTConfigController::loadColumnsFromDB($tableId, array($idColName));
if (count($columnsMeta) == 0) {
$returnResult['error'] = __('Supplied id column not exist.', 'wpdatatables');
echo json_encode($returnResult);
exit();
} else {
$columnMeta = $columnsMeta[0];
if ($columnMeta->id_column) {
$idColumnKey = sanitize_text_field($columnMeta->orig_header);
$deleteRowIds = $rows[$idColumnKey];
foreach ($deleteRowIds as $rowId) {
$rowId = (int)$rowId;
if (empty($rowId)) {
continue;
}
do_action('wpdatatables_excel_before_delete_row', $rowId, $tableId);
$res = $wpdb->delete($mySqlTableName, array($idColumnKey => $rowId));
And this is the solution I am trying to do to prevent the deletion of rows with "Status" = "Cekanje"
$dontdelete = $wpdb -> get_row($wpdb->prepare("SELECT id FROM SaveContactForm7_1 WHERE id != $idKey"));
if($dontdelete)
{
exit();
}