+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Deleting a user error

Deleting a user error

3 posts, 0 answered
  1. Richard
    Richard avatar
    49 posts
    Registered:
    13 Jul 2010
    26 Nov 2013
    Link to this post
    Hello everyone

    I just wish to delete a user from Sitefinity and I am encountering the following error:

    No data provider decorator could be found for the provider 'DynamicModule.ns.Wrapped_ValpakRoleDataProvider_ea66db37a0c74552869fecc7fd948a0b'. The method 'GetDirtyItems()' has to be overridden and implemented.

    How would I go about deleting a user and/or implementing the GetDirtyItems() method?

    Apologies if I'm being thick.
  2. Ivan D. Dimitrov
    Ivan D. Dimitrov avatar
    310 posts
    Registered:
    26 Mar 2015
    29 Nov 2013
    Link to this post
    Hello Richard,

    There is no need to apologize, we know that Sitefinity's learning curve can be steep. In general you do not need to use the GetDirtyItems method in order to delete a user. All you need to do is to get the user by a certain identifier, say Name, and then execute the Delete statement of our UserManager. The code below shows you just that:
    public static void DeleteUser(string username)
    {
        UserManager userManager = UserManager.GetManager();
        UserProfileManager profileManager = UserProfileManager.GetManager();
      
        User user = userManager.GetUsers().Where(u => u.UserName == username).SingleOrDefault();
      
        if (user != null)
        {
            SitefinityProfile userProfile = profileManager.GetUserProfile<SitefinityProfile>(user);
      
            if (userProfile != null)
            {
                profileManager.Delete(userProfile);
            }
      
            userManager.Delete(user);
        }
      
        profileManager.SaveChanges();
        userManager.SaveChanges();
    }

     You can get a clear idea of how to Query users in our Documentation.

    Regards,
    Ivan D. Dimitrov
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Richard
    Richard avatar
    49 posts
    Registered:
    13 Jul 2010
    02 Dec 2013 in reply to Ivan D. Dimitrov
    Link to this post
    Hello Ivan 

    Thank you very much for this information, I'll give it a go now and see how I get on.

    Rich
3 posts, 0 answered