Updated permissions to use new glmMembersUserCan() function.
authorChuck Scott <cscott@gaslightmedia.com>
Thu, 13 Oct 2016 20:14:19 +0000 (16:14 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Thu, 13 Oct 2016 20:14:19 +0000 (16:14 -0400)
setup/permissions.php

index 940ac7d..cc9f2b3 100644 (file)
  * to permit the action.
  *
  * Of course any of these may test more than one capability if that's desired.
+ *
+ * Since we have capabilities that only exist if a particular add-on (such as Contacts)
+ * has been loaded and activated, it can be helpful to be able to test for a capability
+ * for the current user and permit some action if that capability doesn't exist. The
+ * main plugin therefore provides the following globally accessible function that will
+ * return true if the capability doesn't exist, otherwise it respects the capability.
+ *
+ *  glmMembersUserCan('glm_members_edit_any_member', $permit);
+ *
+ *  $permit is a boolean set before this function call for passing on permissions.
  */
 
 // Logged in all members manager user may edit Social media for all members
 add_filter('glm_members_permit_admin_members_social',
     function($permit) {
-        if (!$permit) { return false; }
-        return current_user_can('glm_members_edit_any_member');
+        return glmMembersUserCan('glm_members_edit_any_member', $permit);
     }
 );
 
 // Logged in member user may edit an social media only for their own entity
 add_filter('glm_members_permit_admin_member_social',
     function($permit) {
-        if (!$permit) { return false; }
-        return current_user_can('glm_members_edit_my_member');
+        return glmMembersUserCan('glm_members_edit_my_member', $permit);
     }
 );