Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/*
Plugin Name: New User Roles
Plugin URI: https://github.com/andykillen
Description: Adds additional role(s)
Version: 1.0
Author: Andrew Killen
*/
function new_user_roles_plugin_activation() {
$capibilities = [
'activate_plugins' => false,
'delete_others_pages' => true,
'delete_others_posts' => true,
'delete_pages' => true,
'delete_posts' => true,
'delete_private_pages' => true,
'delete_private_posts' => true,
'delete_published_pages' => true,
'delete_published_posts' => true,
'edit_dashboard' => false,
'edit_others_pages' => true,
'edit_others_posts' => true,
'edit_pages' => true,
'edit_posts' => true,
'edit_private_pages' => true,
'edit_private_posts' => true,
'edit_published_pages' => true,
'edit_published_posts' => true,
'edit_theme_options' => true,
'export' => false,
'import' => false,
'list_users' => true,
'manage_categories' => false,
'manage_links' => true,
'manage_options' => false,
'moderate_comments' => true,
'promote_users' => true,
'publish_pages' => true,
'publish_posts' => true,
'read_private_pages' => true,
'read_private_posts' => true,
'read' => true,
'remove_users' => true,
'switch_themes' => false,
'upload_files' => true,
'customize' => true,
'delete_site' => false,
'update_core' => false,
'update_plugins' => false,
'update_themes' => false,
'install_plugins' => false,
'install_themes' => false,
'upload_plugins' => false,
'upload_themes' => false,
'delete_themes' => false,
'delete_plugins' => false,
'edit_plugins' => false,
'edit_themes' => false,
'edit_files' => false,
'edit_users' => true,
'create_users' => true,
'delete_users' => true,
'unfiltered_html' => true,
];
add_role( 'business_owner', 'Business Owner', $capibilities);
}
register_activation_hook( __FILE__, 'new_user_roles_plugin_activation' );
register_deactivation_hook(__FILE__, 'new_user_roles_plugin_deactivation');
function new_user_roles_plugin_deactivation()
{
remove_role('business_owner');
}
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.