1. Home
  2. Docs
  3. 404 to 301
  4. Actions and Filters for developers

Actions and Filters for developers

404 to 301 comes with a range of so-called filter and action hooks. These hooks allow you to modify certain functionality in the plugin without having to edit the plugin files itself.


This doc is not completed yet. As of now, you may not find all the available hooks here.

As you know, there are two types of hooks: actions and filters.

  • Filters allow you to intercept and modify data as it is processed.
  • Actions allow you to execute code at specific points in a process.

Available Filters

These are the available filters that you can make use of. If you have recommendations, please free to create a pull request or contact us.

Settings & General Filters

General filters for global functions and settings of the plugin.


Enable or Disable global redirect option.

// Enabling redirect.
add_filter( 'jj4t3_redirect_enabled', '__return_true' );


Enable or Disable email notification.

// Enabling email notification.
add_filter( 'jj4t3_email_notify_enabled', '__return_true' );


Enable or Disable error logging.

// Enabling error logs.
add_filter( 'jj4t3_log_enabled', '__return_true' );


Alter redirect to value. Accepts only 2 values – page and link.

// Redirecting to custom link.
function custom_redirect_to( $to ) {

    return 'link';
add_filter( 'jj4t3_redirect_to', 'custom_redirect_to' );


Alter redirect type value. Accepts HTTP status codes for redirects.

Note: If you are adding custom HTTP status codes, please make sure that you have added this value to jj4t3_redirect_statuses filter too. Otherwise, it will skip and use default value

// Setting 301 as redirect status.
function custom_redirect_type( $type ) {

    return 302;
add_filter( 'jj4t3_redirect_type', 'custom_redirect_type' );


Alter human vs bot/crawler check. Return true it set the visitor as a real human. This check is performed to skip email notifications and error logging for bots and crawlers.


  • true/false – to set human or bot.
  • mobile/desktop – current device type if not bot (It will return desktop for bots also).
// Set current visitor as real human. Not a bot.
add_filter( 'j4t3_is_human', '__return_true' );


Filter to set new HTTP status codes for redirects. By default 301, 302 and 307 will be there. Please do not remove these values.

Accepts HTTP status codes for redirectsAs mentioned previously, jj4t3_redirect_type filter has a dependency on this filter.

// Adding new 200 status code.
function custom_redirect_statuses( $statuses ) {

    $statuses['200'] = '200 Redirect';

    return $statuses;
add_filter( 'jj4t3_redirect_statuses', 'custom_redirect_statuses' );

Error Log Listing Filters

Filters available for error logs listing alteration.


Filter the available columns in error log listing. Array of columns with column name as key and Label as value. These values are used in filters, and listing table columns.

// Available column names.
function custom_log_columns( $columns ) {

    $columns = array(
       'date' = 'Date',
       'url' = '404 Path',
       'ref' = 'From',
       'ip' = 'IP Address',
       'ua' = 'User Agent',
       'redirect' = 'Redirect',

    return $columns;
add_filter( 'jj4t3_log_columns', 'custom_redirect_statuses' );


Filter to alter no. of items listed per page. By default, this value is 20. This filter will override the value set from the screen options in listing page.

// Set 30 logs per page.
function custom_logs_list_per_page( $per_page ) {

    return 30;
add_filter( 'jj4t3_logs_list_per_page', 'custom_logs_list_per_page' );


Alter the result generated by SQL query for listing error logs. This result will be after sorting, filtering and pagination.


Using this filter is not recommended. If you alter the structure, the entire listing table may be affected

You may add your custom data as result, or alter the return result. This data will be used by listing table for rendering the output.

// Removing first row from result data.
function custom_jj4t3_logs_list_result( $result ) {

    // Remove first item.
    unset( $result[0] );

    return $result;
add_filter( 'jj4t3_logs_list_result', 'custom_jj4t3_logs_list_result' );


Filter to alter the log listing order by field. Only allowed fields can be used (allowed values can be altered using jj4t3_log_list_orderby_allowed filter). The default value will be “date”.

// Set order by url.
function custom_log_list_orderby( $order_by ) {

    return 'url';
add_filter( 'jj4t3_log_list_orderby', 'custom_log_list_orderby' );


Filter to alter the log listing order by field. Only allowed fields can be used (allowed values can be altered using jj4t3_log_list_orderby_allowed filter). The default value will be “date”.

These values should be there in jj4t3_log_columns filter’s values.

// Remove url from allowed values.
function custom_log_list_orderby_allowed( $allowed ) {

    // Remove url.
    unset( $allowed['url'] );
    return $allowed;
add_filter( 'jj4t3_log_list_orderby_allowed', 'custom_log_list_orderby_allowed' );


Filter to alter the log listing order (Ascending or Descending). Only ASC and DESC will be accepted. The default value will be “DESC”.

// Change to ascending order.
function custom_log_list_order( $order ) {

    return 'ASC';
add_filter( 'jj4t3_log_list_order', 'custom_log_list_order' );


Allowed fields for grouping error log items. These values should be there in jj4t3_log_columns filter’s values.

// Remove ip from allowed values.
function custom_log_list_groupby_allowed( $allowed ) {

    // Remove ip from array.
    unset( $allowed['ip'] );

    return $allowed;
add_filter( 'jj4t3_log_list_groupby_allowed', 'custom_log_list_groupby_allowed' );


Change grouping field in error logs listing. This should be allowed in jj4t3_log_list_groupby_allowed filter.


This filter may not be used to change the total value. Use this filter to change the total value type (like decimal)

Default value is the total returned from database result.

// Set group by url.
function custom_log_list_groupby( $group_by ) {

    return 'url';
add_filter( 'jj4t3_log_list_groupby', 'custom_log_list_groupby' );

How can we help?