Jump to content

How to throw an error if a ticket contains certain words?


Recommended Posts

Posted

Hi,

 

Is there any event or something which can throw error if user create an ticket with certain words such as "bank", "SEO"?

I tried below code but not working:

use Blesta\Core\Util\Events\Common\EventInterface;

    public function handle(array $vars)
    {
        if ($vars['event'] === 'ticket.pre_create') {
            $ticketContent = $vars['ticket']['content'];

            if (stripos($ticketContent, 'bank') !== false) {
               
                throw new \Exception('Ticket cannot contain the word "bank".');
            }
        }
    }

 

Thanks.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...