| | |
| | | $this->content = array_map(function($content) { |
| | | return strtolower($content['plural']); |
| | | },JVB_CONTENT); |
| | | add_action('set_user_role', [$this, 'updateRoles'], 10, 3); |
| | | } |
| | | |
| | | public function updateRoles(int $userID, string $role, array $oldRoles):void |
| | | { |
| | | if (doing_action('set_user_role') > 1) { |
| | | return; |
| | | } |
| | | $temp = jvbNoBase($role); |
| | | if (array_key_exists($temp, JVB_USER)) { |
| | | $user = get_userdata($userID); |
| | | if (!$user) { |
| | | return; |
| | | } |
| | | $this->reset($user); |
| | | $this->setUserAs($user, $temp); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @param WP_User $user |
| | |
| | | /** |
| | | * @param WP_User $user |
| | | * @param string $type |
| | | * @param bool $add |
| | | * |
| | | * @return void |
| | | */ |
| | |
| | | if (empty($capsMap)){ |
| | | $capsMap = [ |
| | | $content, |
| | | str_replace('-', '_',sanitize_title(strtolower(JVB_CONTENT[$content]['plural']))) |
| | | str_replace('-', '_',sanitize_title(strtolower(JVB_CONTENT[$content]['plural']??JVB_TAXONOMY[$content]['plural']))) |
| | | ]; |
| | | return $capsMap[1]; |
| | | } |