Filter uncanny-automator

automator_send_webhook_plain_text_separator

Filters the separator used to join plain text webhook fields, allowing customization of how data is delimited.

add_filter( 'automator_send_webhook_plain_text_separator', $callback, 10, 1 );

Description

This filter hook allows modification of the separator used when formatting webhook data as plain text. Developers can alter the default comma to any other string to customize how fields are joined in plain text webhook payloads.


Usage

add_filter( 'automator_send_webhook_plain_text_separator', 'your_function_name', 10, 1 );

Parameters

$fields (mixed)
This parameter is the default separator string used when joining the fields for plain text webhook output.

Return Value

The filtered value.


Examples

/**
 * Example of how to modify the separator used for plain text webhook fields.
 *
 * This filter allows you to change the character(s) that separate individual fields
 * when the webhook is sent in plain text format.
 *
 * @param string $separator The current separator (default is ',').
 * @param array  $fields    The array of fields to be joined.
 *
 * @return string The new separator to be used.
 */
add_filter( 'automator_send_webhook_plain_text_separator', function( $separator, $fields ) {
    // Let's assume we want to use a pipe symbol '|' instead of a comma for plain text.
    // We can also add logic to conditionally change the separator based on the fields.
    // For this example, we'll just set it to a pipe.

    // You might also want to check if $fields contains specific keys or values
    // to determine if a different separator is appropriate.
    // Example: if ( isset( $fields['order_id'] ) && $fields['order_id'] > 100 ) { ... }

    return '|';
}, 10, 2 );

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/lib/webhooks/class-automator-send-webhook.php:726

),
							$fields
						)
					);
				}
				break;
			case 'plain':
				$fields = implode( apply_filters( 'automator_send_webhook_plain_text_separator', ',', $fields ), $fields );
				break;
			case 'binary':
				$fields = implode( apply_filters( 'automator_send_webhook_binary_separator', ',', $fields ), $fields );
				$fields = $this->string_to_binary_conversion( $fields );
				break;
			case 'html':
				$fields = $this->build_html_table( $fields, $is_check_sample );


Scroll to Top