Skip to content

Instantly share code, notes, and snippets.

@boonebgorges boonebgorges/user-role.php Secret
Last active Aug 29, 2015

What would you like to do?
reset user role in an mu-plugin
* Instructions:
* 1. If you don't have a directory called wp-content/mu-plugins, create it
* 2. Create a file at wp-content/mu-plugins/user-role.php
* 3. Paste the entire contents of this gist into the user-role.php file
* 4. Replace the value of $user_login ('boone1') with your user name
* 5. Replace the value of $user_role ('editor') with your desired role. You probably want 'administrator'
* 6. Save the file
* 7. Load your website in a browser
* 8. Now attempt to visit wp-admin. You should have full access again. Assuming you do, you should immediately delete the user-role.php file (or comment out the add_action() line at the bottom)
function bbg_reset_user_role() {
$user_login = 'boone1';
$user_role = 'editor';
// Don't edit anything below here
$user = get_user_by( 'login', $user_login );
$user->add_role( $user_role );
add_action( 'init', 'bbg_reset_user_role', 100 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.