Updating the glmUser and glmMembersCaps.
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 25 Oct 2016 14:56:28 +0000 (10:56 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 25 Oct 2016 14:56:28 +0000 (10:56 -0400)
Placing these two into the function glmMembersUserCan.
Setting up the glmUser as static variable that will be created only the
first call for the function.
This fixes an issue with network sites.

classes/glmPluginSupport.php

index 6ce8f5a..d0a8cbf 100644 (file)
@@ -498,15 +498,17 @@ function glmMembersInstallErrorsNotice() {
  *
  * @return boolean True if capability exists
  */
-$glmUser = wp_get_current_user();
-$glmMembersCaps = $glmUser->allcaps;
 function glmMembersUserCan( $cap, $permit )
 {
-    global $glmMembersCaps;
+    static $glmUser;
+    if ( !$glmUser ) {
+        $glmUser = wp_get_current_user();
+    }
 
     if (!$permit) {
         return false;
     }
+    $glmMembersCaps = $glmUser->allcaps;
 
     if (!isset($glmMembersCaps[$cap])) {
         return $permit;