我想的是已登录过的用户登录块将用户重定向。我所拥有的是一个包含下面的代码模块:覆盖user_login_submit重定向已认证的用户
附录,2011年9月3日,15:30H:根据kiamlaluno的建议改变的代码。
附录,2011年9月3日,17:08H:小修正:更改节点/管理员联系。
附录,3.9.2011,17:24小时:删除[]
- >代码现在就像这样工作,但不要忘记在DB中更改模块优先级。
function _MYMODULE_user_login_submit($form, &$form_state) {
global $user;
if ($user->uid == 1) {
$form_state['redirect'] = 'admin';
} elseif ($user->uid) {
$form_state['redirect'] = 'node/add/image';
return;
}
}
/**
* Modifies the outfit and behaviour of the user login block.
*/
function MYMODULE_form_user_login_block_alter(&$form, $form_state) {
unset($form['#action']);
// removes the forgot password and register links
$form['links'] = array();
// Redirects the user to the image upload page after login
// This cannot be done by a rule, the rule based redirect is only
// working for the login page not the user login block.
$form['#submit'] = array('_MYMODULE_user_login_submit');
}
它不重定向用户;它好像_MYMODULE_user_login_submit()
简单地被忽略。
我知道的已经:
- 我不能使用规则/触发器,因为我还没有登录过的登录页面,但它总是说,用户登录区块
- :“使用logintoboggan”上的帖子,但在那里我只有“注册”和“确认”的重定向选项,但我需要“身份验证”或“登录后”。
- 反正,我不希望使用更多的模块,我更喜欢PHP的几行。
只是一个侧面说明 - 管理员已的uid 1(代码检查0,这将是匿名用户)。 –
@HenrikOpel:好点。谢谢。 – spikey