Warning: Array to string conversion in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 825

Warning: foreach() argument must be of type array|object, string given in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 830

Warning: Array to string conversion in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 825

Warning: foreach() argument must be of type array|object, string given in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 830
FLSUPPORT_TICKETCREATEDCUSTOMER::fsupport_ticket_opened( $ticket,  $person )

Validation function when the trigger action is hit


Warning: Array to string conversion in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 825

Warning: foreach() argument must be of type array|object, string given in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 830

Warning: Array to string conversion in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 825

Warning: foreach() argument must be of type array|object, string given in /home/customer/www/docs.automatorplugin.com/public_html/wp-content/themes/wporg-developer/inc/template-tags.php on line 830

Parameters Parameters

$ticket

(Required)

$person

(Required)


Source Source

File: src/integrations/fluent-support/triggers/flsupport-ticketcreatedcustomer.php

	public function fsupport_ticket_opened( $ticket, $person ) {
		$user_id = get_current_user_id();
		// Logged in users only.
		if ( ! $user_id ) {
			return;
		}
		$request_uri = isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
		if ( ! strstr( $request_uri, '/customer-portal/tickets' ) ) {
			return; // ticket is not opened by customer.
		}
		if ( ! is_object( $person ) || ! is_object( $ticket ) ) {
			return;
		}
		$pass_args = array(
			'code'           => $this->trigger_code,
			'meta'           => $this->trigger_meta,
			'user_id'        => $user_id,
			'ignore_post_id' => true,
			'is_signed_in'   => true,
		);
		$args = Automator()->maybe_add_trigger_entry( $pass_args, false );
		if ( $args ) {
			foreach ( $args as $result ) {
				if ( true === $result['result'] ) {
					$trigger_meta = array(
						'user_id'        => $user_id,
						'trigger_id'     => $result['args']['trigger_id'],
						'trigger_log_id' => $result['args']['get_trigger_id'],
						'run_number'     => $result['args']['run_number'],
					);
					$trigger_meta['meta_key']   = 'FLSUPPORTTICKETID';
					$trigger_meta['meta_value'] = $ticket->id;
					Automator()->insert_trigger_meta( $trigger_meta );
					$trigger_meta['meta_key']   = 'FLSUPPORTPERSONID';
					$trigger_meta['meta_value'] = $person->id;
					Automator()->insert_trigger_meta( $trigger_meta );
					Automator()->maybe_trigger_complete( $result['args'] );
					break;
				}
			}
		}
	}