hook_civicrm_alterRedirect¶
Summary¶
This hook is called when when the browser is being redirected. This allows extensions to override the destination of an HTTP redirect.
Notes¶
This hook can alter the $url
and $context
from CRM_Utils_System::redirect
.
Definition¶
hook_civicrm_alterRedirect(&$url, &$context)
Parameters¶
- \Psr\Http\Message\UriInterface
&$url
- array
&$context
- optional additional information for the hook.
Returns¶
- null
Availability¶
- This hook was first available in CiviCRM 5.0.0.
Example¶
The alterRedirect
function is prefixed with the full extension name, all lowercase,
followed by _civicrm_alterRedirect
. For an extension "CiviTest" the hook
would be placed in the civitest.php
file and might look like:
function civitest_civicrm_alterRedirect(&$url, &$context)
{
if ($url->getPath() == '/civicrm/contact/view') {
$url = $url->withPath('/my/custom/contact/view');
}
}