You are here

function hook_simplesamlphp_auth_logout_gotourl_alter in simpleSAMLphp Authentication 7.2

Same name and namespace in other branches
  1. 7.3 simplesamlphp_auth.api.php \hook_simplesamlphp_auth_logout_gotourl_alter()

Allow modules to change the url passed to simplesamlphp during logout.

Called when a user logs out of Drupal.

Parameters

string $gotourl: The url to be passed to simplesamlphp.

object $account: The user being logged out.

1 invocation of hook_simplesamlphp_auth_logout_gotourl_alter()
simplesamlphp_auth_user_logout in ./simplesamlphp_auth.module
Implements hook_user_logout().

File

./simplesamlphp_auth.api.php, line 17
Describes hooks provided by the simplesamlphp_auth module.

Code

function hook_simplesamlphp_auth_logout_gotourl_alter(&$gotourl, $account) {

  // Example of reacting to a value on the account.
  if ($account->field_example == 'example_value') {
    $gotourl = url('thanks-for-stopping-by', array(
      'absolute' => TRUE,
    ));
  }

  // Example of adding the destination value to the redirect URL.
  if (isset($_GET['destination'])) {

    // Ensure our redirect URL is absolute.
    $redirect_url = url($_GET['destination'], array(
      'absolute' => TRUE,
    ));

    // Add our redirect URL as a querystring to the full URL.
    $gotourl = $gotourl . '?redirect=' . drupal_encode_path($redirect_url);
  }
}