用户登录时,DNN是否会触发事件? [英] Does DNN fire an event when a user logs in?
问题描述
我正在开发一个模块,以在当前用户登录或在我们的网站上注册新帐户时自动在姐妹网站上创建新用户.注册新帐户时,我已经有该模块运行了.现在,我需要找到一种在用户登录时触发它的方法.非常感谢您提出任何建议或指导.
I'm developing a module to automatically create a new user on a sister website when a current user logs into or registers a new account on our site. I already have the module working when a new account is registered. Now I need to find a way to trigger it when a user logs in. Any suggestions or guidance is most appreciated.
推荐答案
DNN 7.4(Evoq 8.0)为用户和站点添加了事件处理.因此,您可以创建一个实现 IUserEventHandlers
的类,并使用 [Export(typeof(IUserEventHandlers))]
属性对其进行注释,并且只要有用户,DNN就会自动调用您的方法进行身份验证,以及创建,删除,删除和批准.
DNN 7.4 (Evoq 8.0) added event handling for users and sites. So, you can create a class that implements IUserEventHandlers
and annotate it with the [Export(typeof(IUserEventHandlers))]
attribute, and DNN will automatically call your methods whenever a user is authenticated, as well as created, deleted, removed, and approved.
using DotNetNuke.Entities.Users;
[Export(typeof(IUserEventHandlers))]
public class MyUserEventHandlers : IUserEventHandlers
{
public void UserAuthenticated(object sender, UserEventArgs args)
{
SisterSiteLibrary.CreateUserOnSisterSite(args.User);
}
public void UserCreated(object sender, UserEventArgs args)
{
}
public void UserDeleted(object sender, UserEventArgs args)
{
}
public void UserRemoved(object sender, UserEventArgs args)
{
}
public void UserApproved(object sender, UserEventArgs args)
{
}
}
这篇关于用户登录时,DNN是否会触发事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!