Skip to content

Instantly share code, notes, and snippets.

@AKTed
AKTed / wp-reset-roles.php
Last active July 3, 2022 09:45
The following code will reset a WordPress default role to it's default capabilities. Note: these defaults are for WordPress 3.5, any other versions might have different defaults. To be safe, only use this code on WordPress 3.5. Warning: This cannot be undone! The role, in it's current state, is removed and recreated with the WordPress default ro…
<?php
/*
* example usage: $results = reset_role_WPSE_82378( 'subscriber' );
* per add_role() (WordPress Codex), $results "Returns a WP_Role object
* on success, null if that role already exists."
*
* possible $role values:
* 'administrator'
* 'editor'
* 'author'