I am trying to create an “undeletable” admin user in WordPress

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?

Read More

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?

Related posts

4 comments

  1. 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

  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.

Comments are closed.