Using WordPress ‘admin_referrer_policy’ PHP filter

The admin_referrer_policy WordPress PHP filter allows you to modify the admin referrer policy header value.

Usage

add_filter('admin_referrer_policy', 'your_function_name');
function your_function_name($policy) {
  // your custom code here
  return $policy;
}

Parameters

  • $policy (string) – The admin referrer policy header value. Default is ‘strict-origin-when-cross-origin’.

More information

See WordPress Developer Resources: admin_referrer_policy

Examples

Change referrer policy to ‘no-referrer’

Modify the referrer policy to ‘no-referrer’ for admin pages.

add_filter('admin_referrer_policy', 'change_referrer_policy');
function change_referrer_policy($policy) {
  $policy = 'no-referrer';
  return $policy;
}

Use ‘same-origin’ referrer policy

Set the referrer policy to ‘same-origin’ for admin pages.

add_filter('admin_referrer_policy', 'use_same_origin_policy');
function use_same_origin_policy($policy) {
  $policy = 'same-origin';
  return $policy;
}

Use ‘origin’ referrer policy

Set the referrer policy to ‘origin’ for admin pages.

add_filter('admin_referrer_policy', 'use_origin_policy');
function use_origin_policy($policy) {
  $policy = 'origin';
  return $policy;
}

Use ‘strict-origin’ referrer policy

Set the referrer policy to ‘strict-origin’ for admin pages.

add_filter('admin_referrer_policy', 'use_strict_origin_policy');
function use_strict_origin_policy($policy) {
  $policy = 'strict-origin';
  return $policy;
}

Use ‘unsafe-url’ referrer policy

Set the referrer policy to ‘unsafe-url’ for admin pages.

add_filter('admin_referrer_policy', 'use_unsafe_url_policy');
function use_unsafe_url_policy($policy) {
  $policy = 'unsafe-url';
  return $policy;
}