From de07ea53c63f1647039b949807e2338b97d1bc46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Tue, 23 Jun 2020 11:20:50 +0200 Subject: [PATCH 1/3] amp_default_role for logged-in users (that have no explicit role) --- authMgrPlus/plugin.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/authMgrPlus/plugin.php b/authMgrPlus/plugin.php index a1a2aab..94f71b1 100644 --- a/authMgrPlus/plugin.php +++ b/authMgrPlus/plugin.php @@ -219,6 +219,7 @@ function amp_have_capability( $capability ) { global $amp_anon_capabilities; global $amp_role_capabilities; global $amp_admin_ipranges; + global $amp_default_role; // Make sure the environment has been setup amp_env_check(); @@ -253,6 +254,12 @@ function amp_have_capability( $capability ) { break; } } + if( !$return ) { + if ( isset( $amp_default_role ) && in_array ($amp_default_role, array_keys( $amp_role_capabilities ) ) ) { + $default_caps = $amp_role_capabilities [ $amp_default_role ]; + $return = in_array( $capability, $default_caps ); + } + } return $return; } From 496fbf6d4098abebba063071064f98edce386f3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Tue, 23 Jun 2020 11:23:10 +0200 Subject: [PATCH 2/3] Document "add_default_role" --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 68d8555..4198522 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,12 @@ $amp_allowed_plugin_pages = array( ``` Explore the code to see how to set `$amp_role_capabilities` and `$amp_anon_capabilities`. These are set to defaults in the `amp_env_check()` function. +You can also assign a default role to all logged-in users that have no explicit role: +``` +$amp_default_role = "Editor"; +``` + + #### NOTE: This is a fork of nicwaller's [Authmgr](https://github.com/nicwaller/yourls-authmgr-plugin) merged with Ian barber's[Seperate User's](https://github.com/joshp23/Yourls-Separate-Users) plugin. Both code bases underwent heavy rewrites, and have been extensively updated and tightly integrated here, resulting in a lean and highly functional user authorization management environment. From d108d422907e786acc09d1ae7375cbfab6674242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?IOhannes=20m=20zm=C3=B6lnig?= Date: Wed, 24 Jun 2020 18:16:08 +0200 Subject: [PATCH 3/3] Bumped version number --- authMgrPlus/plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/authMgrPlus/plugin.php b/authMgrPlus/plugin.php index 94f71b1..c4ec980 100644 --- a/authMgrPlus/plugin.php +++ b/authMgrPlus/plugin.php @@ -3,7 +3,7 @@ Plugin Name: Auth Manager Plus Plugin URI: https://github.com/joshp23/YOURLS-AuthMgrPlus Description: Role Based Access Controlls with seperated user data for authenticated users -Version: 2.1.2 +Version: 2.2.0 Author: Josh Panter, nicwaller, Ian Barber Author URI: https://unfettered.net */