You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2021-12-03 16:14:00

aziz
Member
Registered: 2021-03-30
Posts: 109

When a ticket is created call php script plugin

Hello guys,

I need to create a simple plugin so when a ticket is created, I get its data and execute a PHP script.
I did this but it doesn't work.I just need to know the changes that should be done.

This is my Setup.php

<?php
/*
 setup.php 
*/

function plugin_init_MyPlugin()
{
  global $PLUGIN_HOOKS;
  $PLUGIN_HOOKS['item_add']['MyPlugin'] = 'plugin_item_add_MyPlugin';
  $PLUGIN_HOOKS['csrf_compliant']['MyPlugin'] = true;
}

function plugin_version_MyPlugin()
{
  return [ 'name'           => 'MyPlugin',
           'version'        => '1.0',
           'author'         => 'laroussi_aziz',
           'license'        => 'GPLv2+',
           'homepage'       => '',
           'requirements'   => [
              'glpi' => [
                 'min' => '9.3',
                 'dev' => true
              ]
           ]
         ];
}
function plugin_MyPlugin_install() { return true; }

function plugin_MyPlugin_check_prerequisites() { return true; }
function plugin_MyPlugin_check_config() { return true; }

?>

and this is the hook.php :

<?php
/* hook.php */

// After an item is added
function plugin_item_add_MyPlugin($data)
{

	
  // My PHP script
}

This plugin seems to be so simple, but I didn't know how to pull it off because I'm new to PHP. So hope that someone can guide me through this I really appreciate it  and I need this so much!

Last edited by aziz (2021-12-03 16:41:49)

Offline

Board footer

Powered by FluxBB