Filter
uncanny-automator-pro
uap_option_all_flsupport_customer_agent
Filters the customer agent option for Fluent Support integrations.
add_filter( 'uap_option_all_flsupport_customer_agent', $callback, 10, 1 );
Description
This filter allows developers to modify the options array for selecting a customer agent in Fluent Support integrations. Use it to add, remove, or alter agent options before they are displayed in Uncanny Automator recipes. The `$option` parameter contains the full array of select field settings.
Usage
add_filter( 'uap_option_all_flsupport_customer_agent', 'your_function_name', 10, 1 );
Parameters
-
$option(mixed) - This parameter contains the option value being filtered, representing a choice between 'anyone', 'customer', or 'agent' for Fluent Support ticket ownership.
Return Value
The filtered value.
Examples
<?php
/**
* Example filter for 'uap_option_all_flsupport_customer_agent'.
* This filter allows modifying the options passed to the Fluent Support
* customer/agent selection in Uncanny Automator Pro.
*
* In this example, we'll add a new option to potentially include
* a specific user role as an agent if they are not already listed.
*
* @param array $option The current option array, typically containing 'label', 'input_type', 'required', 'options', and 'relevant_tokens'.
* @return array The modified option array.
*/
add_filter( 'uap_option_all_flsupport_customer_agent', function( $option ) {
// Check if the option structure is as expected and if we have agents to modify.
if ( ! is_array( $option ) || ! isset( $option['options'] ) || ! is_array( $option['options'] ) ) {
return $option;
}
// Define a specific user role we want to ensure is available as an agent.
$target_role = 'custom_support_manager';
$target_label = 'Custom Support Manager';
// Flag to check if the target role already exists in the options.
$role_exists = false;
foreach ( $option['options'] as $value => $label ) {
// If the value (often a user ID or role slug) matches our target, mark it as existing.
if ( $value === $target_role ) {
$role_exists = true;
break;
}
}
// If the target role doesn't exist, add it to the options.
if ( ! $role_exists ) {
// In a real scenario, you might need to dynamically fetch users with this role
// and add them as options. For this example, we're just adding the role slug.
// Uncanny Automator Pro might expect user IDs for agent selection, so adjust accordingly.
// This example assumes the 'options' array can accept role slugs or other identifiers.
$option['options'][ $target_role ] = $target_label;
}
// You could also remove specific agents if needed, for example:
// unset( $option['options']['some_user_id_to_remove'] );
return $option;
}, 10, 1 ); // Priority 10, accepts 1 argument.
?>
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/helpers/flsupport-pro-helpers.php:87
public function all_person_types( $label, $option_code, $args = array() ) {
if ( ! $label ) {
$label = esc_attr__( 'Customer or agent', 'uncanny-automator-pro' );
}
$options = array(
'-1' => esc_attr__( 'anyone', 'uncanny-automator-pro' ),
'customer' => esc_attr__( 'a customer', 'uncanny-automator-pro' ),
'agent' => esc_attr__( 'an agent', 'uncanny-automator-pro' ),
);
$option = array(
'option_code' => $option_code,
'label' => $label,
'input_type' => 'select',
'required' => true,
'options' => $options,
'relevant_tokens' => array(),
);
return apply_filters( 'uap_option_all_flsupport_customer_agent', $option );
}