DotNetNuke ‘Un-Register’ Hack
So you are using DotNetNuke but you don’t want the users to be able to ‘un-register’ themselves, but you still want the administrator to be able to delete a user. You can use this un-register hack to accomplish this.
This is really a simple change to the code in fact you can make the change in any text editor. I am going to make a couple of assumptions here. First that you have the version of DotNetNuke that you will be installing on your server on your development machine. Second you are a little familiar with where DotNetNuke keeps things.
Ok here we go. You will need to find the file named ‘User.aspx.vb’. You can find this file in the following path: ‘..DesktopModulesAdminSecurityUser.aspx.vb’. Be careful because there is another file named ‘Users.aspx.vb’ this is the incorrect file.
Open the file with your choice of text editor. You will want to find the method titled ‘DataBind()’.
In this method you need to find the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | If IsUser Then cmdDelete.ResourceKey = "UnRegister" Else cmdDelete.ResourceKey = "Delete" End If You need to change the above code to the following: If IsUser AND Not IsAdmin Then cmdDelete.ResourceKey = "UnRegister" cmdDelete.Visible = False Else cmdDelete.ResourceKey = "Delete" End If |
I’ve highlighted in blue the code that needs to be added. The reason this works is that everyone is a user so really the if statement is always true. By adding in the Not and IsAdmin this makes this only true for registered users and not for the admin or host accounts. Then using the cmdDelete.Visible = False statement this allows the control to load like normal, but it will not show up on the page. This avoids breaking anything else in DotNetNuke code.
This is the change that worked for me.