function __login_destination_should_we_redirect in Login Destination 6.2
A helper function to determine whether redirection should happen.
Return value
bool TRUE - do redirect, FALSE - do NOT redirect.
1 call to __login_destination_should_we_redirect()
- login_destination_user in ./
login_destination.module - Implementation of hook_user().
File
- ./
login_destination.module, line 293 - Control where users are directed to, once they login
Code
function __login_destination_should_we_redirect($account) {
global $user;
// don't redirect on registration's password reset
// not clear if this affects anything. Can't hurt. At least the wrong redirection does not happen currently. Phew!
// Also check for force_password_change
if (arg(0) == 'user' && arg(1) == 'reset' || module_exists('force_password_change') && isset($account->force_password_change) && $account->force_password_change && $account->uid == $user->uid) {
return FALSE;
}
$mode = variable_get('ld_condition_type', LOGIN_COND_ALWAYS);
if ($mode == LOGIN_COND_ALWAYS) {
return TRUE;
}
else {
$cond = variable_get('ld_condition_snippet', '');
if ($mode == LOGIN_COND_PAGES) {
$page_match = FALSE;
$path = drupal_get_path_alias($_GET['q']);
$page_match = drupal_match_path($path, $cond);
if ($path != $_GET['q']) {
$page_match = $page_match || drupal_match_path($_GET['q'], $cond);
}
return $page_match;
}
elseif ($mode == LOGIN_COND_SNIPPET) {
return drupal_eval('<?php ' . $cond . ' ?>');
}
}
}