Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David Muir 6 posts 26 karma points
    May 09, 2012 @ 10:09
    David Muir
    0

    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.

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    May 10, 2012 @ 02:08
    Bo Damgaard Mortensen
    0

    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

  • David Muir 6 posts 26 karma points
    May 11, 2012 @ 12:14
    David Muir
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft