Call a script after user add

Discussion in 'Plugins/Modules/Addons' started by darkness_08, Jan 3, 2017.

  1. darkness_08

    darkness_08 New Member

    Hey,
    is there a way to call a external script after adding a customer to the interface.
    I found the ispconfig/server/plugins-available directory.
    But I think it must be in the interface part,right?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer


    Yes. See interface/lib/plugins/

    I use a similar plugin in the billing module, here a first few lines to get an idea how to bind your function to the events:

    Code:
    class billing_plugin {
    
        var $plugin_name        = 'billing_plugin';
        var $class_name         = 'billing_plugin';
    
        /*
                This function is called when the plugin is loaded
        */
        function onLoad() {
            global $app;
    
            //* Events
            $app->plugin->registerEvent('client:client:on_after_update', 'billing_plugin', 'client_update');
            $app->plugin->registerEvent('client:client:on_after_insert', 'billing_plugin', 'client_insert');
            $app->plugin->registerEvent('client:client:on_after_delete', 'billing_plugin', 'client_delete');
            $app->plugin->registerEvent('client:client:on_check_delete', 'billing_plugin', 'client_before_delete');
    
            $app->plugin->registerEvent('client:reseller:on_after_update', 'billing_plugin', 'client_update');
            $app->plugin->registerEvent('client:reseller:on_after_insert', 'billing_plugin', 'client_insert');
            $app->plugin->registerEvent('client:reseller:on_after_delete', 'billing_plugin', 'client_delete');
            $app->plugin->registerEvent('client:reseller:on_before_delete', 'billing_plugin', 'client_before_delete');
    
    
    And an important note! The interface plugins are read into the session at login, so when you create a new plugin, then logout and login again to activate it :) You don't have to repeat that when you change it (unless you want to register it for additional events).
     
    Jesse Norell likes this.
  3. darkness_08

    darkness_08 New Member

    Thx,
    i got the Code working. After adding a client the plugin is called.
    But how can I access to the client data (name, email, ...).
    Sorry, but I'm not familiar with PHP.
     
  4. florian030

    florian030 Well-Known Member HowtoForge Supporter

    Did you check $page_form->dataRecord ?
     
  5. darkness_08

    darkness_08 New Member

    I will check.
    How can I show the content of a object? I tried print_r($object) but got only a white page.
     
  6. florian030

    florian030 Well-Known Member HowtoForge Supporter

    You use
    print_r($page_form);exit;
    in the first line of your function.
     

Share This Page