I have a 'Basic Page' node that contains PHP code which returns the following error, when I edit and save it:

Error 101 (net::ERR_CONNECTION_RESET): The connection was reset.

I believe it is not the real error; if I edit anything but the code, I don't get any error.

What I do is changing <?php if (user_is_logged_in()): ?> to <?php if (user_is_logged_in() && (inarray('approved user', $GLOBALS['user']->roles)))): ?>.

I'm pretty positive the code is right; the PHP filter is enabled, and the administrator user is the only user who can use it. I'm not really sure what else could be the issue.

  • 2
    As side comment, in Drupal you normally don't check if the user has a specific role, but if the user has a specific permission, which means you normally call user_access().
    – apaderno
    Feb 6, 2012 at 18:04
  • @kiamlaluno I think you mean user_access(). user_permission() is the user module's implementation of hook_permission()
    – Clive
    Feb 17, 2012 at 3:20
  • Whoops, you are right. I edited my comment. :)
    – apaderno
    Feb 17, 2012 at 3:57

1 Answer 1


inarray() isn't a PHP function, you're probably looking for in_array() :)

The error you're getting is probably masking the internal Call to undefined function inarray() exception that would be thrown.


You also have one too many closing parentheses at the moment, I'd recommend separating out your code to make it cleaner:


$has_required_role = in_array('approved user', $GLOBALS['user']->roles);
if (user_is_logged_in() && $has_required_role):
  // Do something

  • no, i still get the same with in_array().
    – pandabrand
    Feb 6, 2012 at 18:59
  • @pandabrand Please check the updated answer
    – Clive
    Feb 6, 2012 at 19:40
  • nope, still the same response
    – pandabrand
    Feb 6, 2012 at 20:20
  • ok, that was weird I had to take out the space in the if statement (user_is_logged_in()&&$has_required_role) worked, strange.
    – pandabrand
    Feb 6, 2012 at 20:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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