From 3aada9949d51024a92a8b5c6cb70d12f9c3cac16 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 21 Dec 2025 19:59:48 +0000
Subject: [PATCH] =auth refactored via rest, referral system set up for Jane, some javascript consolidation
---
inc/managers/RoleManager.php | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/inc/managers/RoleManager.php b/inc/managers/RoleManager.php
index 417c2ee..4913bc4 100644
--- a/inc/managers/RoleManager.php
+++ b/inc/managers/RoleManager.php
@@ -19,8 +19,24 @@
$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
@@ -140,7 +156,6 @@
/**
* @param WP_User $user
* @param string $type
- * @param bool $add
*
* @return void
*/
@@ -410,7 +425,7 @@
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];
}
--
Gitblit v1.10.0