Created
October 18, 2018 12:36
-
-
Save techjewel/9da3af0dd1f7fdee87e7576682a3bde8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Say you have table which table id is 101 and you want to filter some data | |
* Please disable caching for this table and load using ajax renderer | |
*/ | |
add_filter('ninja_tables_get_public_data', function ($data, $tableId) { | |
if($tableId != 101) { | |
return $data; // Return if this is not our target table | |
} | |
$modifiedData = array(); | |
foreach ($data as $item) { | |
// say you have a column key as 'item_date' and you want to check the date if valid or not | |
if(isset($item['item_date']) & ninjaCustomIsValidDate($item['item_date'])) { | |
$modifiedData[] = $item; | |
} | |
} | |
return $data; | |
}); | |
function ninjaCustomIsValidDate($date) { | |
// calculate and return true / false | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can I use this to modify my table data in any other ways?