Main Content

Clone the WordPress Administrator Role

WordPress Admin IconIf you’re looking to create new roles in WordPress, and you’re open to using a plugin, I recommend User Role Editor. It works very well.

However, sometimes you don’t need a plugin. If you want to clone the Administrator role and all the capabilities you don’t need a plugin for that.

Here’s the code to create a new user with all Administrative capabilities. This can be added to your theme’s functions.php file and it will run when you load any page.

Once the user is created, you can delete the code as it’s no longer needed.

When the new user is created, this gives them all the capabilities. If you know what you’re doing, then you’re good. If you’re not sure, use a plugin which gives you a better interface for managing capabilities.

This code also includes some custom capabilities for plugins I had installed at the time. So BuddyPress, bbPress, Events Manager Pro, some donation plugins. It’s not the cleanest, but it works.

Want to remove a custom user role? That’s actually really easy with the remove_role function.

Want to see what capabilities the administrator, or any role, currently have on your site? For that, use the get_role function. I took the output of that function, did some find/replace and then created the code that’s above.

It’s important to note that this code was created May 2016 and if WordPress adds new capabilities, those won’t be added automatically. If you add new plugins with custom capabilities, those won’t be added either. That’s where a plugin comes in handy.

Leave a Reply