74 lines
1.8 KiB
PHP
74 lines
1.8 KiB
PHP
<?php
|
|
|
|
use WoWPress\Models\User;
|
|
|
|
function set_roles()
|
|
{
|
|
remove_role('editor');
|
|
remove_role('contributor');
|
|
remove_role('author');
|
|
remove_role('subscriber');
|
|
|
|
$admin = get_role('administrator');
|
|
|
|
add_role('gildenmeister', __('Gildenmeister'), ['read' => true]);
|
|
$gm = get_role('gildenmeister');
|
|
|
|
add_role('offizier', __('Offizier'), ['read' => true]);
|
|
$offi = get_role('offizier');
|
|
|
|
add_role('raidlead', __('Raidlead'), ['read' => true]);
|
|
$rl = get_role('raidlead');
|
|
|
|
add_role('raider', __('Raider'), ['read' => true]);
|
|
$raider = get_role('raider');
|
|
|
|
add_role('novize', __('Novize'), ['read' => true]);
|
|
$novize = get_role('novize');
|
|
|
|
add_role('f_f', __('F&F'), ['read' => true]);
|
|
$ff = get_role('f_f');
|
|
|
|
add_role('nobody', __('Niemand'));
|
|
|
|
update_option('default_role', 'nobody');
|
|
|
|
$admin->add_cap('wowpress_edit_site', true);
|
|
$admin->add_cap('wowpress_edit_raids', true);
|
|
$admin->add_cap('wowpress_edit_characters', true);
|
|
$admin->add_cap('wowpress_view_raids');
|
|
|
|
foreach (get_role('administrator')->capabilities as $cap => $status) {
|
|
$gm->add_cap($cap, $status);
|
|
$offi->add_cap($cap, $status);
|
|
}
|
|
|
|
$rl->add_cap('wowpress_edit_raids', true);
|
|
$rl->add_cap('wowpress_edit_characters', true);
|
|
|
|
$rl->add_cap('wowpress_view_raids');
|
|
$raider->add_cap('wowpress_view_raids');
|
|
$novize->add_cap('wowpress_view_raids');
|
|
}
|
|
|
|
|
|
function isAllowed($capability)
|
|
{
|
|
if (!current_user_can($capability)) :
|
|
include plugin_dir_path(__FILE__) . '../pages/404.php';
|
|
die;
|
|
endif;
|
|
}
|
|
|
|
|
|
function setGlobalUser(){
|
|
global $user;
|
|
$user = get_current_user_id();
|
|
if ($user) {
|
|
$user = User::find($user);
|
|
} else {
|
|
$user = new User();
|
|
$user->ID = 0;
|
|
$user->login = "Gast";
|
|
}
|
|
} |