How to redirect user to a specific page after they

2019-01-26 09:55发布

We have certain users in our member list that have a role "vendor" attached to them. All such members are to be redirected to a certain page upon login. How can this be accomplished?

8条回答
ゆ 、 Hurt°
2楼-- · 2019-01-26 10:09

following condition for hook_user

if($op =='login') drupal_goto("your path");
查看更多
啃猪蹄的小仙女
3楼-- · 2019-01-26 10:10

You can use Rules

Events: User has logged in.
Condition: User has role
Actions: Page redirect

查看更多
祖国的老花朵
4楼-- · 2019-01-26 10:14

There are modules that do this (besides Trigger+Actions), such as LoginDestination: http://drupal.org/project/login_destination. This Drupal forum post has a bit more info about it as well.

查看更多
Explosion°爆炸
5楼-- · 2019-01-26 10:16

For Drupal 7

Action --> admin/config/system/actions - Redirect to URL

then enable your trigger module

Trigger --> /admin/structure/trigger/node

if your are trying to login redirect just follow this(select user tab in the page)

go to --> admin/structure/trigger/user

then Trigger: After a user has logged in

choose an action -->Redirect to URL and assign.

Then clear the cache.

It will work for you!

查看更多
甜甜的少女心
6楼-- · 2019-01-26 10:18

There are 2 ways in DRUPAL 7

1) Using action and trigger see this http://drupal.org/node/298506

2)if using custom module

function YOURMODULE_user_login(&$edit, $account) {

 if (!isset($_POST['form_id']) || $_POST['form_id'] != 'user_pass_reset' || variable_get('login_destination_immediate_redirect', FALSE)) {

 if(in_array('THE-ROLE-WANTED-TO-REDIRECT',$account->roles)): 

drupal_goto('PATH');

 else: drupal_goto('user/'.$account->uid); 

endif; 

} 

}
查看更多
等我变得足够好
7楼-- · 2019-01-26 10:25

This can be achieved by using a combination of content access and login toboggan modules. You'll be able to restrict pages and prompt user to login to access them.

查看更多
登录 后发表回答