added roles to archive plugin

This commit is contained in:
jorge 2022-03-30 16:40:03 +02:00
parent 32629a052d
commit ca282817b2
2 changed files with 49 additions and 0 deletions

View File

@ -56,6 +56,8 @@ include( ARCHIVE_WPPLUGIN_PATH . 'includes/arcHIVE-init-textdomain.php');
include( ARCHIVE_WPPLUGIN_PATH . 'includes/arcHIVE-enable-svg.php');
include_once( ARCHIVE_WPPLUGIN_PATH . 'includes/arcHIVE-add-roles.php');
if ( is_admin() ) {
//include_once( plugin_dir_path( __FILE__ ) . 'includes/arcHIVE-admin-stylesheet.php' );
include( ARCHIVE_WPPLUGIN_PATH . 'includes/arcHIVE-admin-stylesheet.php');

View File

@ -0,0 +1,47 @@
<?php
/**
* Add roles for users
*
* @link https://arc-hive.zone
* @since 1.1.0
*
* @package archive_wpplugin
* @subpackage archive_wpplugin/includes
*/
/**
* Add roles for users
*
* This class defines all code necessary to run during the plugin's activation.
*
* @since 1.1.0
* @package archive_wpplugin
* @subpackage archive_wpplugin/includes
* @author Jorge - vitrubio.net <jorge@vitrubio.net>
*/
// create new roles on plugin activation
// https://developer.wordpress.org/reference/functions/add_role/
function archive_wpplugin_add_roles_on_plugin_activation() {
// if ( get_option( 'custom_roles_version' ) < 1 ) {
$resourceeditorcapabilities = array(
'read' => true,
'level_0' => true
);
$resourceauthorcapabilities = array(
'read' => true,
'level_0' => true
);
$resourceauthorcapabilities = array(
'read' => true,
'level_0' => true
);
remove_role('archive_resource_editor');
add_role( 'archive_resource_editor', 'Resource Editor', $resourceeditorcapabilities );
remove_role('archive_resource_author');
add_role( 'archive_resource_author', 'Resource Author', $resourceauthorcapabilities );
remove_role('archive_resource_contributor');
add_role( 'archive_resource_contributor', 'Resource Contributor', $resourcecontributorcapabilities );
// update_option( 'custom_roles_version', 1 );}
}
register_activation_hook( __FILE__, 'archive_wpplugin_add_roles_on_plugin_activation' );