Guest Support for Joomla! - Documentation

Guest Support utilizes the Joomla! plugin system with the group guestsupport. Therefore, the initial step is to create a standard Joomla! plugin and install it using Joomla!'s extension installer. You can learn how to create a Joomla! plugin by referring to the official Joomla! documentation available here: https://docs.joomla.org/Portal:Plugin_Development

To define the plugin group, modify the extension tag in the plugin's XML file as shown below:

<extension type="plugin" group="guestsupport" method="upgrade">

To use the methods below, add the following namespace in the plugin's PHP file:

use Joomla\Event\Event;

The Guest Support extension includes several events organized into the following groups:

  1. Ticket Creation Events
    1. onGuestsupportBeforeCreatingTicket(Event $event)
    2. onGuestsupportAfterCreatingTicket(Event $event)
  2. Ticket Reply Events
    1. onGuestsupportBeforeCreatingReply(Event $event)
    2. onGuestsupportAfterCreatingReply(Event $event)
  3. Ticket View Events
    1. onGuestsupportTicketAfterDepartment(Event $event)
    2. onGuestsupportTicketBeforeOtherTickets(Event $event)
    3. onGuestsupportTicketAfterOtherTickets(Event $event)

1. Available Ticket Creation Events:

onGuestsupportBeforeCreatingTicket(Event $event)

This event is triggered after the user submits a ticket, verifying the reCAPTCHA and the OTP, but before creating the ticket. The $event object includes the following parameters:

  • 'context': The value is 'guestsupport.createticket'.
  • 'data': This parameter contains the user-submitted POST data. This data has not been sanitized yet.
  • 'cancelTicket': You can set this value to true if you want to abort the ticket creation. This will redirect the user to the ticket creation page without creating the ticket. You should set a Joomla! system message explaining why the ticket was aborted, so the user is informed.

Here is a basic example demonstrating how to abort the ticket creation and add a string before the ticket subject::

/**
 * Triggered before creating ticket.
 */
public function onGuestsupportBeforeCreatingTicket(Event $event)
{
  // Abort ticket creation
  if ( $condition_failed )
  {
    $this->app->enqueueMessage("The error message", 'error');
    $event->setArgument('cancelTicket', true);
  }

  // Add a string before the subject
  $arguments = $event->getArgument('data');
  $arguments['subject'] = 'The string: ' . $arguments['subject'];
  $event->setArgument('data', $arguments);
}

onGuestsupportAfterCreatingTicket(Event $event)

This event is triggered after a ticket has been successfully created and just before displaying the confirmation message or redirecting to the ticket view page. The $event object includes the following parameters:

  • 'context': The value is 'guestsupport.createticket'.
  • 'data': This parameter contains the submitted ticket data.

2. Available Ticket Reply Events:

onGuestsupportBeforeCreatingReply(Event $event)

This event is triggered after the user submits a reply to a ticket. The $event object includes the following parameters:

  • 'context': The value is 'guestsupport.createticket'.
  • 'data': This parameter contains the submitted reply data.
  • 'is_agent': The value is true when the reply is submitted by a support agent and false when the reply is submitted by the user.
  • 'cancelReply': You can set this value to true if you want to abort the reply. This will redirect the user to the ticket page without creating the reply. You should set a Joomla! system message explaining why the reply was aborted, so the user is informed.

onGuestsupportAfterCreatingReply(Event $event)

This event is triggered after a reply has been successfully created and just before redirecting to the ticket view page. The $event object includes the following parameters:

  • 'context': The value is 'guestsupport.createticket'.
  • 'data': This parameter contains the submitted reply data.
  • 'is_agent': The value is true when the reply is submitted by a support agent and false when the reply is submitted by the user.

3. Available Ticket View Events:

Ticket view events are utilized to display additional information on the right sidebar of the ticket view page. You can use the following events to display customized information to the support agent, the user, or both. Additionally, you can customize contents based on the ticket form.

Following events accept array with result Argument. Here is an example:

/**
 * Triggered to display contents after the department section/text.
 */
public function onGuestsupportTicketAfterDepartment(Event $event)
{
  $contents_array = [];
  $contents_array[] = "Generate some texts."
  $event->setArgument('result', $contents_array);
}

onGuestsupportTicketAfterDepartment(Event $event)

This event is triggered to display contents after the department section/text. The $event object includes the following parameters:

  • 'context': The value is 'guestsupport.ticket'.
  • 'ticket': This parameter contains the ticket data with the initial message. This also includes the form ID
  • 'is_agent': The value is true when the ticket is being viewed by a support agent and false when the ticket is being viewed by the user.

onGuestsupportTicketBeforeOtherTickets(Event $event)

This event is triggered to display contents before the other tickets section. The $event object includes the following parameters:

  • 'context': The value is 'guestsupport.ticket'.
  • 'ticket': This parameter contains the ticket data with the initial message. This also includes the form ID
  • 'is_agent': The value is true when the ticket is being viewed by a support agent and false when the ticket is being viewed by the user.

onGuestsupportTicketAfterOtherTickets(Event $event)

This event is triggered to display contents after the other tickets section. The $event object includes the following parameters:

  • 'context': The value is 'guestsupport.ticket'.
  • 'ticket': This parameter contains the ticket data with the initial message. This also includes the form ID
  • 'is_agent': The value is true when the ticket is being viewed by a support agent and false when the ticket is being viewed by the user.