//请问大家有熟悉drupal的吗?我想在user.module中的user_authenticate函数中插入一段script,请问如何做?
function user_authenticate($name, $pass) {
global $user;
// Try to log in the user locally. Don't set $user unless successful.
if ($account = user_load(array('name' => $name, 'pass' => $pass, 'status' => 1))) {
// Check if the e-mail is denied by an access rule.
// Doing this check here saves us a user_load() in user_login_validate()
// and introduces less code change for a security fix.
if (drupal_is_denied('mail', $account->mail)) {
form_set_error('name', t('The name %name is registered using a reserved e-mail address and therefore could not be logged in.', array('%name' => $account->name)));
return;
}
else {
//我想在登陆成功后在这里插入一段script,请问如何插入,试了一个晚上,用drupal_add_js总是不行 $user = $account;
return $user;
}
}
除非你将JS设置成Server 或者 在PHP中用上echo('<script type=javascript></script>');输出到客户端运行
echo '<script type=javascript> alert("插入东西拉!");</script>';
<div id=""> echo "这里插入提示之类语言!";</div>
else {
?>
<script type='javascript'> alert("要显示的js!"); </script>
<?
$user = $account;
你用echo有输出,而且输出为空,当然就为空了。drupal有专门的调用js的函数drupal_add_js, 你为何不用呢?
return 的是 $user 和 之前 用一句 echo ' <script type=javascript> alert("插入东西拉!"); </script>'; 应该没有什么关系或者是 return 后,进行 判断if (user_authenticate($name, $pass)) {
//...
cho ' <script type=javascript> alert("插入东西拉!"); </script>';
} else {
//..
}