Filter uncanny-automator

automator_field_logger_ignored_meta_keys

Filters a list of meta keys that the Automator Field Logger will ignore when saving data.

add_filter( 'automator_field_logger_ignored_meta_keys', $callback, 10, 2 );

Description

Filters the list of meta keys that are ignored by the field logger. Developers can use this to prevent sensitive or irrelevant meta data from being logged. This hook fires when retrieving ignored meta keys, allowing for dynamic exclusion of specific keys.


Usage

add_filter( 'automator_field_logger_ignored_meta_keys', 'your_function_name', 10, 2 );

Parameters

$this (mixed)
This parameter is a filterable array containing meta keys that should be ignored by the Automator's field logger.
$this (mixed)
This parameter contains the current array of meta keys that are being ignored by the logger.

Return Value

The filtered value.


Examples

add_filter( 'automator_field_logger_ignored_meta_keys', 'my_automator_exclude_specific_meta_keys', 10, 2 );

/**
 * Excludes specific meta keys from being logged by the Automator plugin.
 *
 * This function is an example of how to use the 'automator_field_logger_ignored_meta_keys'
 * filter to prevent certain post meta data from being recorded in the Automator logs.
 * This can be useful for preventing sensitive information or transient data from being logged.
 *
 * @param array<string> $ignored_meta_keys An array of meta keys that are currently ignored.
 * @param object        $resolver          The fields resolver object instance.
 *
 * @return array<string> The modified array of ignored meta keys.
 */
function my_automator_exclude_specific_meta_keys( $ignored_meta_keys, $resolver ) {

	// Add custom meta keys to the ignored list.
	// For example, let's ignore any meta keys starting with '_wc_session_'
	// and also a specific key like 'my_plugin_transient_data'.
	$custom_ignored_keys = array(
		'_wc_session_%', // Example: Ignore WooCommerce session data
		'my_plugin_transient_data', // Example: Ignore a specific custom transient
	);

	// Combine existing ignored keys with our custom ones.
	$all_ignored_keys = array_unique( array_merge( $ignored_meta_keys, $custom_ignored_keys ) );

	return $all_ignored_keys;
}

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/core/services/resolver/fields-resolver.php:149

public function get_ignored_meta_keys() {
		return apply_filters( 'automator_field_logger_ignored_meta_keys', $this->ignored_meta_keys, $this );
	}

Scroll to Top