Copied to clipboard

Flag this post as spam?

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


  • Ryan Dansie 17 posts 98 karma points
    Mar 11, 2016 @ 13:36
    Ryan Dansie
    0

    un-delete a user type

    I have inherited an Umbraco project which appears to have had the "Administrators" user type deleted (my assumption based on the fact that it doesn't appear in the user types list). There is a user type called "ADMIN" which was probably added manually by my predecessor.

    From looking in the database I can see the original user type with id 1 and the extra user type with id 5.

    I would like to restore the original user type but can't see anything obvious in the database marking this user type as deleted. I would be grateful if somebody could somebody point me in the right direction.

    My Umbraco version is 7.2.8.

  • Dennis Adolfi 1082 posts 6449 karma points MVP 6x c-trib
    Mar 11, 2016 @ 14:58
    Dennis Adolfi
    0

    I dont know about un-deleting, but you could use this package to reset the default admin user: https://our.umbraco.org/projects/developer-tools/umbraco-admin-reset/

  • Ryan Dansie 17 posts 98 karma points
    Mar 11, 2016 @ 15:33
    Ryan Dansie
    0

    Thanks for the suggestion. I had a look at that project and it effectively just resets the password and unlocks the admin user. Doesn't do anything with the user types. Below is pretty much it:

    var user = UmbracoContext.Current.Application.Services.UserService.GetUserById(0);
                if (user != null)
                {
                    user.Username = "Admin";
                    user.IsApproved = true;
                    user.IsLockedOut = false;
    
                    //Save changes
                    UmbracoContext.Current.Application.Services.UserService.Save(user);
                    //Change password
                    UmbracoContext.Current.Application.Services.UserService.SavePassword(user, "Admin1234!");
                }
    
Please Sign in or register to post replies

Write your reply to:

Draft