0

As explained in the reply of this post by the Advanced Access Manager's author I've changed the current getCurrentUserRole function in the path /wp-content/plugins/advanced_access_manager/module with this new code:

function getCurrentUserRole() {
    if (is_object($this->data) && isset($this->data->{$this->cap_key})) {
       $result = $this->data->{$this->cap_key};
    } else {
       $result = array();
    }    
    return $result;
}

But I get an error when trying to access through www.foosite.com/wp-admin. Here is the apache log error message:

PHP Fatal error: Cannot access empty property in /var/www/foosite/wp-content/plugins/advanced-access-manager/module/class-module_user.php on line 29

The line error corresponds with the if statement, so I've tried to fix it using isset:

function getCurrentUserRole() {
    if (isset($this->data) && is_object($this->data) && is_array($this->data->{$this->cap_key})) {
        $result = array_keys($this->data->{$this->cap_key});
    } else {
        $result = array();
    }
    return $result;
}

Unfortunately the error remains the same.

Any suggestions?

1

Here is the solution I've made that it's now working properly:

function getCurrentUserRole() {
  if (isset($this->data) && isset($this->data->{$this->cap_key}) && is_object($this->data) && is_array($this->data->{$this->cap_key}) ) {
     $result = array_keys($this->data->{$this->cap_key});
  } else {
     $result = array();
  }

  return $result;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.