Tuesday, August 8, 2017

How to change user role account name for the subscriber, editor, author, or contributor accounts in wordpress

Sick of the "Contributor", "Subscriber", "Editor", "Author" or other lame account names wordpress sends out to define the default user roles that come with it's User Account System? I don't know why, I just always hated the role name "Subscriber", so I wasted an hour of my life trying to figure out how to change it. You would think that updating a user account role would be easy peazy Japanezy...but even with a great plugin like User Role Editor it's not as easy as you'd think.

The main purpose of the user role editor is to make editing user roles and capabilities a lot easier, so updating the name and slug / base of a user role wasn't the original intention of the user role editor.

That being said, I discovered this simple hack before I wasted $10 on a plugin that does the exact same thing. 

Here's the thing that confused me, I kept trying to figure out how to change the actual account name associated with the user role. So, in the case of "Subscriber", I wanted that user account name to be simply "User". After looking through way too many useless sites, talking about "blah blah blah, you have to add this custom code to the child theme while singing three blind mice and standing on your head ...more blah blah blah yakadee schmackadee." 

Don't think of changing the user role name and slug/base in that light. Instead, think of it as a migration. Clone the user role w/ the capabilities you are looking for to a new account w/ the role name and role slug / base of your choosing. Here's the hack that I used that will hopefully save you guys some time:


That's how simple it is, so you can imagine I was both peeved and a bit embarassed by how elementary the solution was. Keep in mind I have yet to fully test the implementation, but if this post is more than a few hours old, you can guess I didn't run into any significant issues.

No comments:

Post a Comment

Feel free to send along any questions, comments, or hacks you'd like to see :)