简体   繁体   English

登录后重定向到不同角色的不同URL

[英]Redirect to different URL for different roles after login

I have created 2 different roles in WordPress: writer and copy-writer , with only "read" capability (so they can change their profile only) 我在WordPress中创建了2个不同的角色: writercopy-writer ,仅具有“读取”功能(因此他们只能更改其个人资料)

Also, I have developed a plugin. 另外,我开发了一个插件。

So after the user logs into the ADMIN panel, they are taken to the "profile" page, but I need them to be taken to my plugin page 因此,在用户登录到ADMIN面板后,它们被带到“个人资料”页面,但我需要将它们带到我的插件页面

Any ideas on how to achieve the above functionality? 关于如何实现上述功能的任何想法?

check for the redirecting page (from where user is redirected after successful login), add conditional statement to check the user role and then redirect accordingly. 检查重定向页面(成功登录后从中重定向用户),添加条件语句以检查用户角色,然后进行相应的重定向。

if($role=="whatever role you want to check")
  // redirect to plugin page
else
  // redirect to profile page (the default behavior)
add_action('login_redirect','my_function');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM