Action uncanny-automator-pro

fluent_support/before_ticket_create

Fires before a new ticket is created, providing access to ticket data and customer information.

add_action( 'fluent_support/before_ticket_create', $callback, 10, 2 );

Description

Fires before a ticket is created in Fluent Support. Developers can use this hook to modify ticket data or customer information before the ticket is saved to the database. This provides an opportunity for custom integrations or data manipulation.


Usage

add_action( 'fluent_support/before_ticket_create', 'your_function_name', 10, 2 );

Parameters

$ticket_data (mixed)
This parameter contains an array of data intended to be used for creating a new Fluent Support ticket.
$customer (mixed)
This parameter contains an array of data that will be used to create a new support ticket.

Examples

add_action( 'fluent_support/before_ticket_create', function ( $ticket_data, $customer ) {

    // Example: Add a custom tag to the ticket if the customer has a specific meta key.
    // Assuming $customer is a WP_User object or has a method to access user meta.
    if ( $customer && is_callable( array( $customer, 'get_user_meta' ) ) ) {
        $assigned_user_id = get_user_meta( $customer->ID, 'fluent_support_assigned_user', true );

        if ( ! empty( $assigned_user_id ) ) {
            // Ensure 'tags' key exists and is an array
            if ( ! isset( $ticket_data['tags'] ) || ! is_array( $ticket_data['tags'] ) ) {
                $ticket_data['tags'] = array();
            }

            // Add a custom tag based on the assigned user
            $ticket_data['tags'][] = 'assigned-to-' . sanitize_title( get_user_by( 'id', $assigned_user_id )->display_name );
            $ticket_data['tags'] = array_unique( $ticket_data['tags'] ); // Remove duplicates
        }
    }

    // Example: Set a default priority if none is provided.
    if ( empty( $ticket_data['priority'] ) ) {
        $ticket_data['priority'] = 'Normal';
    }

    // Note: If this were a filter hook, you would need to return the modified $ticket_data.
    // For action hooks, modifications are made directly to the passed by reference variables or by affecting external state.
    // In this case, $ticket_data is likely passed by reference by the original do_action call if it's designed that way,
    // or the intention is to modify it before it's used in the next step (FluentSupportAppModelsTicket::create).
    // However, as shown in the source context, $ticket_data is passed by value to do_action, so direct modification
    // within this callback won't affect the original $ticket_data in the source.
    // For this example to have a practical effect on the created ticket, the original `do_action` would need to pass
    // $ticket_data by reference, or the action would need to be a filter.

}, 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:257

/*
			 * Action before ticket create
			 *
			 * @param array  $ticketData
			 * @param object $customer
			 */
			do_action( 'fluent_support/before_ticket_create', $ticket_data, $customer ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores

			$created_ticket = FluentSupportAppModelsTicket::create( $ticket_data );

			/*
			 * Action on ticket create
			 *
			 * @param object $createdTicket


Scroll to Top