I have a setup whereby when creating Umbraco Users (not members), that I must copy there details to another table in another database. This is done by using a trigger at the database level.
My table, in the other database, has a unique value it's email column. This is populated by the email address of the Umbraco User.
I need to prevent the Umbraco User being saved if the User being created in Umbraco has the same email address as a user in my table, and preferably notify the user of the issue.
When hooking up to the event you can perform the checks you want and then cancel the event when needed :-)
I wrote a little blogpost on using events to automatically create documents and usergroups when a document of a certain type gets created: http://bit.ly/njDf5g
I believe you can just hit e.Cancel; (correct me if I'm wrong here) to cancel the even from occuring.
I initially took this approach, however, it's a bit of a red herring I'm afraid.
The EventArgs on the new User events are just the standard EventArgs. As a result, you can't cancel the saving of the user by using e.Cancel.
The other issue I have with this is that when you create a new user, they are added to the table without an email address. Not sure how to get round this either :(
I have created a custom MemershipProvider and overridden the base one, which allows me to add custom logic. It works for saving exsiting users, just not for the new users with the blank email addresses.
Prevent Umbraco User being Saved
Hi,
I have a setup whereby when creating Umbraco Users (not members), that I must copy there details to another table in another database. This is done by using a trigger at the database level.
My table, in the other database, has a unique value it's email column. This is populated by the email address of the Umbraco User.
I need to prevent the Umbraco User being saved if the User being created in Umbraco has the same email address as a user in my table, and preferably notify the user of the issue.
Is there any way that this can be achieved?
Thanks in advance
David.
Hi David,
Yes, you should be able to hook into the User New event when it occurs, taken from: http://our.umbraco.org/wiki/reference/api-cheatsheet/using-applicationbase-to-register-events/overview-of-all-events
User
umbraco. BusinessLogic.User
Saving
New
Disabling
Deleting
FlushingFromCache
When hooking up to the event you can perform the checks you want and then cancel the event when needed :-)
I wrote a little blogpost on using events to automatically create documents and usergroups when a document of a certain type gets created: http://bit.ly/njDf5g
I believe you can just hit e.Cancel; (correct me if I'm wrong here) to cancel the even from occuring.
Let me know if it makes sense :-)
All the best,
Bo
Hi Bo,
I initially took this approach, however, it's a bit of a red herring I'm afraid.
The EventArgs on the new User events are just the standard EventArgs. As a result, you can't cancel the saving of the user by using e.Cancel.
The other issue I have with this is that when you create a new user, they are added to the table without an email address. Not sure how to get round this either :(
I have created a custom MemershipProvider and overridden the base one, which allows me to add custom logic. It works for saving exsiting users, just not for the new users with the blank email addresses.
Thank,
DM
is working on a reply...