How to send notification on some action from Splynx

Hi, for example, I used situation when password was modified:

#!/usr/bin/php
<?php


/*
* don`t edit this block !!!!
*/
// Define STDIN
defined('STDIN') OR define('STDIN', fopen('php://stdin', 'r'));

// Get all data. Its is in JSON so we must decode it
$data = fgets(STDIN);

// Decode JSON
$data = json_decode($data, true);

/*
* to send email edit this block
*/
$log_file = '/tmp/log_file.txt';   // I used log-file to see what happens
$model = print_r($data,1); //print data-array
file_put_contents($log_file, "{$model}\n", FILE_APPEND); // print data-array in file

$pass_changed = array_key_exists('password', $data['changed_attributes']); // check if password was modified
if ($pass_changed) {  // if pass was modified, then do something 
    file_put_contents($log_file, "old password - {$data['changed_attributes']['password']['value']}\n",  FILE_APPEND); // in this example I print old password
}
1 Like