wpdatatables_filter_source_data_on_auto_update_cache

Contents

Description

This filter is used to determine whether source data should be filtered during the auto-update process for the wpDataTables cache.

Usage

add_filter( 'wpdatatables_filter_source_data_on_auto_update_cache', 'filter_auto_update_cache', 10, 2 );

Parameters

  • $filterSourceData boolean
    Default is `true`, meaning the source data will be sanitized unless modified by the filter.
  • $tableID integer
    The ID of the table being updated.

Examples

// Callback function for the wpdatatables_filter_source_data_on_auto_update_cache filter hook
function filter_auto_update_cache($filterSourceData, $tableID) {
    // Disable filtering for a specific table ID
    if ($tableID == 1) { // Replace 1 with your table ID
        return false;
    }

    // Enable filtering only for administrators
    if (!current_user_can('administrator')) {
        return true;
    }

    return $filterSourceData;
}

add_filter( 'wpdatatables_filter_source_data_on_auto_update_cache', 'filter_auto_update_cache', 10, 2 );