From 13dead44e1d8e290e2cb06e7e97b15a29e1148fd Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Thu, 13 Oct 2016 16:05:46 -0400 Subject: [PATCH] Added a function plugin support to test for existing capabilities and their setting. --- classes/glmPluginSupport.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/classes/glmPluginSupport.php b/classes/glmPluginSupport.php index 918e655b..bceff41f 100644 --- a/classes/glmPluginSupport.php +++ b/classes/glmPluginSupport.php @@ -489,4 +489,29 @@ function glmMembersInstallErrorsNotice() { delete_option('glmMembersInstallErrors'); } +/** + * Check if a particular capability exists for the current user and if it's checked + * + * If $permit is already false, we just return that since we can only withdraw permission with these tests, not add it. + * @param $cap string Capability to check + * @param $permit boolean Used to pass on pre-existing permission value + * + * @return boolean True if capability exists + */ +$glmUser = wp_get_current_user(); +$glmMembersCaps = $glmUser->allcaps; +function glmMembersUserCan( $cap, $permit ) +{ + global $glmMembersCaps; + + if (!$permit) { + return false; + } + + if (!isset($glmMembersCaps[$cap])) { + return $permit; + } +trigger_error('TEST',E_USER_NOTICE); + return current_user_can($cap); +} -- 2.17.1