-
-
Save boonebgorges/4ee64723ba75caa3c7e1 to your computer and use it in GitHub Desktop.
reset user role in an mu-plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 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