How can we help?

Search for answers or browse our knowledge base.

Table of Contents

Hooks for custom activity log extensions for WP Activity Log

When using WP Activity Log, you can develop your own activity log extension. You might need one to keep a log of changes that take place on a custom-built theme or plugin. Or you might want to keep a log of changes on a plugin that we do not support yet.

Building an activity log add-on for WP Activity Log is very simple. In this page we list the hooks you need to use when developing your own activity logs add-on to:

  • declare new event type and object (refer to activity log metadata for more information on what these are),
  • change the text and URL of the link to post editor in the event message

For more information and detailed code examples of how to develop custom activity log add-ons refer to the custom activity log events documentation.

Event types and objects hooks

Adding new event types

Filter: wsal_event_type_data
Purpose:
Use this filter to add a new event type in the activity log. This filter is passed as an array where the key is the event handle, and the value is the text to be shown in lists.

Code example

/*
add_filter( 'wsal_event_type_data', 'myCustomEventTypes', 10, 1 );
     function myCustomEventTypes( $event_types ) {
     $event_types['new-event'] = __( 'New Event', 'your-textdomian' );
       $event_types['other-event'] = __( 'Other Event', 'your-textdomian' );
     asort( $event_types ); // sort the items so they appear in lists alphabetically
     return $event_types;
}

Adding new objects

Filter: wsal_event_objects
Purpose: The same process we have for event types applies to new objects. Use this  filter to add new objects to lists. Use the wsal_event_object_text filter to add the display text for the new objects used in other places, such as the viewer.

Code example

/*
add_filter( 'wsal_event_objects', 'myCustomEventObjects', 10, 1 );
    function myCustomEventObjects( $objects ) {
    $objects['new-object'] = __( 'New Object', 'your-textdomian' );
	$objects['another-object'] = __( 'Another Object', 'your-textdomian' );
    asort( $objects ); // sort the items so they appear in lists alphabetically
    return $objects;
}

When the plugin reports a change in a post or a user profile, it adds a link in the event message for the user to open the post in the editor or the user profile page. Such links are highlighted in the below screenshot:

The link to the editor or user profile in the activity log message

However, in your custom activity log add-on you might be monitoring something else, such as forms, or products. In such case use the below filter to change the anchor test and URL .

Filter: wsal_link_filter

Code example

/*
/**
 * @param array $value - The URL to link to.
 * @param array $name - Custom meta name.
 * @return string
 */

function wsal_add_custom_meta_format_value( $value, $name ) {
	$check_value = (string) $value;
	if ( '%CustomMeta%' === $name ) {
		if ( 'NULL' !== $check_value ) {
			return '' . __( 'View custom item in the editor', 'wp-security-audit-log' ) . '';
		} else {
			return '';
		}
	}
	return $value;
}

add_filter( 'wsal_link_filter', 'wsal_add_custom_meta_format_value', 10, 2 );
Uploading WP 2FA as a zip file in WordPress
WP 2FA in the WordPress plugin repository
Close

Installing WP 2FA Free

Congratulations on taking the first step towards enhancing your WordPress site's security with WP 2FA Free! You're now on your way to protecting your valuable data and ensuring peace of mind. No coding or technical knowledge is required.

 

Below are two ways to install WP 2FA on your website:

Go to your plugin dashboard on your site, then go to "Add New", and then search for WP 2FA.

Download the WP 2FA plugin zip, then select upload in your plugin dashboard under "Add New".

OPTION 1

OPTION 2

Uploading CAPTCHA 4WP as a zip file in WordPress
CAPTCHA 4WP in the WordPress plugin repository
Close

Installing CAPTCHA 4WP Free

Well done you. You're one step closer to safeguarding your WordPress website from spam and automated attacks with CAPTCHA 4WP. You'll be able to effortlessly integrate CAPTCHA into your forms and enjoy a website with enhanced security.

 

Below are two ways to install CAPTCHA 4WP on your website:

Go to your plugin dashboard on your site, then go to "Add New", and then search for CAPTCHA 4WP.

Download the CAPTCHA 4WP plugin zip, then select upload in your plugin dashboard under "Add New".

OPTION 1

OPTION 2

Uploading WP Activity Log as a zip file in WordPress
WP Activity Log in the WordPress plugin repository
Close

Installing WP Activity Log Free on your website

You deserve a pat on the back for choosing to record user actions and changes on your website. That is the first step towards better user accountability, easier troubleshooting of website security, and many other benefits of issues.

 

Below are the two ways to install WP Activity Log on your website:

Go to your plugin dashboard on your site, then go to "Add New" and then search for WP Activity Log.

Download the WP Activity Log plugin zip, then select upload in your plugin dashboard under "Add New".

OPTION 1

OPTION 2

Uploading Melapress Login Security as a zip file in WordPress
Melapress Login Security in the WordPress plugin repository
Close

Installing Melapress Login Security Free

Congratulations on taking control of your WordPress website's security by implementing robust login and password policies with Melapress Login Security. You can change your login page URL, limit failed login attempts, and reset passwords.

 

Below are two ways to install Melapress Login Security on your website:

Go to your plugin dashboard on your site, then go to "Add New" and then search for Melapress Login Security.

Download the Melapress Login Security plugin zip, then select upload in your plugin dashboard under "Add New".

OPTION 1

OPTION 2