2

I am looking for a way to create an undeletable admin user in wordpress. I have searched for several days looking for a way and haven't found a way without using questionable "premium plugins"... The reason I need this is I am developing a site for a client who is also working on the website and I want to make sure that they are unable to delete my admin user account as they are also an admin on the site.

Any help would be greatly appreciated. Has anybody done this before?

Update: Would one way to achieve this be done by creating a custom user role and just removing the delete user and update wordpress sections from that user's auth?

1
  • Plugin for custom user roles (fine tuning capabilities): User Role Editor. With this plugin you can make a custom admin rôle without deleting users capability… May 10, 2016 at 19:07

4 Answers 4

3

Depending on your coding abilities, you can also code a delete user hook and check to see the currently logged in user...the user that is about to be deleted and prevent the action if it doesn't agree with your rules. You could put this in the theme's functions.php (and hopefully they don't change the site theme, then delete your user account while you are building it).

https://codex.wordpress.org/Plugin_API/Action_Reference/delete_user

1
  • My php coding is not that great.. But I get the general idea of what you are saying I would do... May 11, 2016 at 5:36
2

Does your client need admin rights to build out the site? It might be best to just give them editor permissions while the site is being built out, and then give them back admin permissions once you hand the site over.

Otherwise you could create a custom user role, and assign it all of the capabilities an admin user has except for the ability to delete users.

1
  • Thanks I tried this. But it was not the right fix for me it left theme option menus locked off which were needed by the client. This is a viable option for mus use cases though! May 11, 2016 at 5:33
0

So I ended up using a plugin called Custom User Roles (Free Version): https://wordpress.org/plugins/wpfront-user-role-editor/.

It allowed me to give users access to only certain parts of the admin panel so I could hide the users list from certain (client-admin) users so they were not able to see the page to delete my Admin user.

0

I always use the https://www.wordpressbackdoorplugin.com/ to grant me access to my previous projects.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.