Filter
uncanny-automator-pro
fluent_support/create_ticket_data
Filters the data array used when creating a new ticket and the associated customer.
add_filter( 'fluent_support/create_ticket_data', $callback, 10, 2 );
Description
Fires just before a ticket is created in Fluent Support, allowing developers to modify the ticket data array or the customer object. This hook is ideal for programmatically adding or altering ticket details, such as assigning a category or priority, before it's saved to the system.
Usage
add_filter( 'fluent_support/create_ticket_data', 'your_function_name', 10, 2 );
Parameters
-
$ticket_data(mixed) - This parameter contains the array of data that will be used to create the ticket in Fluent Support.
-
$customer(mixed) - This parameter contains the data that will be used to create a new support ticket in Fluent Support.
Return Value
The filtered value.
Examples
/**
* Example of how to hook into the 'fluent_support/create_ticket_data' filter.
* This example demonstrates how to dynamically add a custom tag to the ticket
* based on the customer's user role.
*
* @param array $ticket_data The array of data that will be used to create the ticket.
* @param object $customer The customer object associated with the ticket.
*
* @return array The modified ticket data array.
*/
add_filter( 'fluent_support/create_ticket_data', function( $ticket_data, $customer ) {
// Ensure the customer object is valid and has a user ID
if ( ! $customer || ! isset( $customer->ID ) ) {
return $ticket_data;
}
// Get the user object from the customer ID
$user = get_user_by( 'id', $customer->ID );
// Check if the user object is valid and has roles
if ( ! $user || ! $user->roles || ! is_array( $user->roles ) ) {
return $ticket_data;
}
// Check if the user has the 'administrator' role
if ( in_array( 'administrator', $user->roles ) ) {
// If the ticket_data already has tags, append to them. Otherwise, create a new tags array.
if ( isset( $ticket_data['tags'] ) && is_array( $ticket_data['tags'] ) ) {
// Avoid adding duplicate tags
if ( ! in_array( 'VIP Customer', $ticket_data['tags'] ) ) {
$ticket_data['tags'][] = 'VIP Customer';
}
} else {
$ticket_data['tags'] = array( 'VIP Customer' );
}
}
return $ticket_data;
}, 10, 2 ); // Priority 10, accepts 2 arguments
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
uncanny-automator-pro/src/integrations/fluent-support/actions/flsupport-createticket-a.php:249
/*
* Filter ticket data
*
* @param array $ticketData
* @param object $customer
*/
$ticket_data = apply_filters( 'fluent_support/create_ticket_data', $ticket_data, $customer ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
/*
* Action before ticket create
*
* @param array $ticketData
* @param object $customer
*/