Filter Since 7.0 uncanny-automator

automator_field_value_sanitized

Filters the sanitized field value before it's processed. Allows third-party plugins and internal code to customize sanitization logic for specific transports or use cases. Filters the sanitized field value before processing, allowing customization for specific transports and field types.

add_filter( 'automator_field_value_sanitized', $callback, 10, 6 );

Description

This filter hook, `automator_field_value_sanitized`, allows developers to modify field values after they have been sanitized but before they are processed. It's ideal for custom sanitization logic based on field type, transport, or the specific field object. Developers can alter the `$sanitized` value to meet unique integration needs.


Usage

add_filter( 'automator_field_value_sanitized', 'your_function_name', 10, 6 );

Parameters

$sanitized (mixed)
The sanitized value.
$original (mixed)
The original value before sanitization.
$type (string)
The resolved field type (may be 'markdown' or 'html').
$field_code (string)
The field code (meta key).
$transport (string)
The transport identifier (e.g., 'rest', 'mcp').
$field (Field)
The field object (for advanced use).

Return Value

The filtered value.


Examples

<?php
/**
 * Example of how to use the 'automator_field_value_sanitized' filter.
 *
 * This example demonstrates how to modify a sanitized field value based on its type and field code.
 * Specifically, it will convert all markdown-formatted text to uppercase if the field type is 'markdown'
 * and the field code is 'user_bio'.
 *
 * @param mixed  $sanitized  The sanitized value.
 * @param mixed  $original   The original value before sanitization.
 * @param string $type       The resolved field type (may be 'markdown' or 'html').
 * @param string $field_code The field code (meta key).
 * @param string $transport  The transport identifier (e.g., 'rest', 'mcp').
 * @param Field  $field      The field object (for advanced use).
 * @return mixed The potentially modified sanitized value.
 */
function my_automator_modify_sanitized_field_value( $sanitized, $original, $type, $field_code, $transport, $field ) {

	// Check if the field is of type 'markdown' and has the field code 'user_bio'.
	if ( 'markdown' === $type && 'user_bio' === $field_code ) {
		// Convert the sanitized markdown content to uppercase.
		// In a real-world scenario, you might want to perform more complex markdown processing or validation.
		if ( is_string( $sanitized ) ) {
			$sanitized = strtoupper( $sanitized );
		}
	}

	// Return the potentially modified sanitized value.
	return $sanitized;
}
add_filter( 'automator_field_value_sanitized', 'my_automator_modify_sanitized_field_value', 10, 6 );
?>

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/api/services/field/class-field-sanitizer.php:108

* @param mixed  $sanitized  The sanitized value.
		 * @param mixed  $original   The original value before sanitization.
		 * @param string $type       The resolved field type (may be 'markdown' or 'html').
		 * @param string $field_code The field code (meta key).
		 * @param string $transport  The transport identifier (e.g., 'rest', 'mcp').
		 * @param Field  $field      The field object (for advanced use).
		 */
		$sanitized = apply_filters(
			'automator_field_value_sanitized',
			$sanitized,
			$value,
			$type_value,
			$field_code,
			$transport,
			$field


Scroll to Top