Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 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;
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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