Extending the Logtivity Plugin

The code in this guide can help you make modifications to the data that that is stored in Logtivity. You can add this code to your site’s theme or plugins.

wp_logtivity_instance

This action allows you to access the Logtivity_Logger instance just before it is sent to Logtivity. You have access here to modify, remove, add any information to the log as well as stop the log from storing if you so wish.

For example, here we cancel sending to Log to Logtivity if the action contains the text ‘Page was Updated’. This might be useful if there were only a handful of logs to you were concerned about and would rather disable the rest.

add_action('wp_logtivity_instance', function($Logtivity_Logger) {

    if (strpos($Logtivity_Logger->action, 'Page was updated') !== false) {
        $Logtivity_Logger->stop();
    }

});

wp_logtivity_get_user_meta

An alternative approach is using the available filters. This filter passes an array of user meta which can be modified or added to. You must return the array at the end even if it is empty.

add_filter('wp_logtivity_get_user_meta', function($value) {

    return $value;

});

wp_logtivity_get_meta

This filter similar to the one above, passes an array of meta data being passed to Logtivity. This information can be modified, added to or removed. You must return the array at the end for this to work.

add_filter('wp_logtivity_get_meta', function($value) {

    return $value;

});