PHP code example of matfish / craft-activity-log

1. Go to this page and download the library: Download matfish/craft-activity-log library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

matfish / craft-activity-log example snippets



return [
 'requestFilter' => function () {
        if ($this->isAjax) {
            return $this->isActionRequest && count($this->actionSegments) === 2 && $this->actionSegments[1] === 'save-draft';
        }

        return true;
    }
]
 
'viewFilters'=> [
        [
            'users'=>['admin'], // Username(s) of relevant users
            'filters'=>[ // Filters to be applied for said users:
                'isCp'=>true, // Only Control Panel requests
                'isAction'=>true, // Only Action requests 
                'isAjax'=>false, // Only page Requests
                'siteId'=>1, // or (e.g) [1,2] for multiple sites
                'actions'=>[ // Only display those actions 
                    ['user-settings','save-group'] // full action array, can be found under `actionSegments` in `activitylog` table
                ]
            ]
        ]
   
 'filterPayloadKeys'=>[
        'cvv','long_number'
    ]

 'filterPayloadCallbacks'=> [
     function(\craft\web\Request $request) {
        if (str_contains($request->getUrl(),'add-credit-card')) {
                return 'cvv';
         }

        // Don't add any key to the list
        return false;
      }
]

php craft plugin/install activity-logs
bash
php craft activity-logs/logs/prune --days=30