WowPress-Tailwind/theme/inc/config-functions.php

74 lines
1.8 KiB
PHP
Raw Normal View History

2024-04-15 23:07:29 +02:00
<?php
2024-04-22 15:38:22 +02:00
use WoWPress\Models\User;
2024-04-15 23:07:29 +02:00
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);
2024-04-22 15:38:22 +02:00
$admin->add_cap('wowpress_view_raids');
2024-04-15 23:07:29 +02:00
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);
2024-04-22 15:38:22 +02:00
$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";
}
2024-04-15 23:07:29 +02:00
}