如果用户属于某个角色,如何在用户登录后将用户重定向到特定页面? [英] How to redirect user to a specific page after they login if they belong to a certain role?

查看:15
本文介绍了如果用户属于某个角色,如何在用户登录后将用户重定向到特定页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的成员列表中有某些用户附加了供应商"角色.所有此类成员在登录时都将被重定向到某个页面.如何实现?

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?

推荐答案

你可以在 Drupal 中定义动作和触发器:

You can define actions and triggers in Drupal:

操作(admin/settings/actions)- 重定向到特定页面

触发器(admin/build/trigger/user)- 用户登录后

试试这个.

创建一个小模块来检查用户的登录过程他拥有什么角色,然后在必要时重定向.drupal_goto => drupal 中的重定向功能

Create a small module to check on a user's login process what role he has and then redirect if neccesary. drupal_goto => redirect-function in drupal

hook_user =>触发用户操作

对于用户的角色:

GLOBAL $user;
$roles = $user->roles;
$vendor = in_array('vendor', $roles);

$vendor 然后持有一个真/假值将决定是否重定向.

$vendor then holds a true/false value will decide to redirect or not.

如果您不知道该怎么做,请在此处发帖,我会为您编写模块.但这可能是为您编写未来的 drupa 模块的好习惯.:)

If you don't know how to do this, just post here and I'll write the module for you. But this would be a good practice for writing future drupa modules for you perhaps. :)

这篇关于如果用户属于某个角色,如何在用户登录后将用户重定向到特定页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆