WordPress Hooks

Redirection can be extended and customised using WordPress actions and filters.

To use these you will need to add the hooks to your own plugin or to your theme’s functions.php file.

Request Information

The following WordPress filters are available for customisation of a server requests:

  • redirection_request_url – The requested URL
  • redirection_request_agent – The requesters user agent
  • redirection_request_referrer – The requesters referrer
  • redirection_request_ip – The requesters IP address
  • redirection_request_cookie – Return a cookie value. Passed cookie value
  • redirection_request_header – The request HTTP header

Logging

The following WordPress filters are available for customisation of logged data:

  • redirection_404_data – Data to be inserted into the 404 table
  • redirection_log_data – Data to be inserted into the redirect log table
  • redirection_log_404 – Return true if the current 404 page should be logged, false otherwise
  • redirection_log – Action fired when something is logged

Note that returning false from the filter will bypass the log.

Redirect source and target

  • redirection_url_source – The original URL used before matching a request. Return false to stop any redirection
  • redirection_url_target – The target URL after a request has been matched (and after any regular expression captures have been replaced). Return false to stop any redirection

Actions

  • redirection_do_nothing – Called when a ‘do nothing’ action fires

Management

  • redirection_permalink_changed – return boolean if a post’s permalink has changed
  • redirection_remove_existing – fired when a post changes permalink and we need to clear existing redirects that might affect it
  • redirection_monitor_created – fired when a redirect is created for a monitor post type. Supplied with the new redirect, old post, and post ID
  • redirection_monitor_types – Modify what post types are monitored by Redirection
  • redirection_create_redirect – Modify redirect data before a redirect is created
  • redirection_update_redirect – Modify redirect data before a redirect is updated
  • redirection_validate_redirect – Validate redirect data
  • red_default_options – The default Redirection options
  • redirection_save_options – Modify options before they are saved
  • redirection_redirect_deleted – Action fire when a redirect is deleted
  • redirection_redirect_updated – Action fire when a redirect is updated/created
  • redirection_redirect_deleted – Action fire when a redirect is deleted

Additionally, if the target URL is a number without any slashes then Redirection will treat it as a post ID and redirect to the full URL for that post.

search previous next tag category expand menu location phone mail time cart zoom edit close