How to redirect user to a specific page after they login if they belong to a certain role?

后端 未结 9 846
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-11 04:26

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 ac

9条回答
  •  有刺的猬
    2020-12-11 04:56

    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; 
    
    } 
    
    }
    

提交回复
热议问题