From 0c609c85d898a3cf30ce2e3bd2cb1f3e4304ee7b Mon Sep 17 00:00:00 2001 From: Mathieu Valois Date: Tue, 14 May 2024 11:55:27 +0200 Subject: [PATCH] fix: fixes issue where default role was not correctly applied --- authMgrPlus/plugin.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/authMgrPlus/plugin.php b/authMgrPlus/plugin.php index a59ffe7..cb84404 100644 --- a/authMgrPlus/plugin.php +++ b/authMgrPlus/plugin.php @@ -268,14 +268,15 @@ function amp_have_capability( $capability ) { // List capabilities of particular user role $user = defined('YOURLS_USER') ? YOURLS_USER : NULL; $user_caps = array(); - if ( amp_user_is_assigned ( $user ) ) + if ( amp_user_is_assigned ( $user ) ){ foreach ( $amp_role_capabilities as $rolename => $rolecaps ) if ( amp_user_has_role( $user, $rolename ) ) $user_caps = array_merge( $user_caps, $rolecaps ); + } - elseif ( isset( $amp_default_role ) && in_array ($amp_default_role, array_keys( $amp_role_capabilities ) ) ) + elseif ( isset( $amp_default_role ) && in_array ($amp_default_role, array_keys( $amp_role_capabilities ) ) ){ $user_caps = $amp_role_capabilities [ $amp_default_role ]; - + } $user_caps = array_unique( $user_caps ); // Is the requested capability in this list? $return = in_array( $capability, $user_caps );