How can I tell a block to appear on user profiles, like /user/1, but not on other pages where the beginning of the path is the same? So for instance, if I have a view set up at /user/1/articles, or user/1/messages, how can I tell the block to appear in the main user profile but not on the articles or messages pages?

2 Answers 2


I believe your only option is to use a PHP snippet to set the visibility.

Under Visibility settings select Pages on which this PHP code returns TRUE (experts only) copy and paste the snippet below.

if (arg(0) == 'user' && !arg(2)) return TRUE;

For this to work you would also need to enable the PHP filter module.

Note that it's not generally recommended to use the PHP filter, but in some cases it might be the easiest solution.

  • Yeah that ended up working. Why exactly is it not recommended to use the php filter?
    – Mrweiner
    Jan 20, 2013 at 5:09
  • 1
    Check out this answer, and this page on drupal.org for the general reasons.
    – dxc
    Jan 20, 2013 at 6:38

Try making it visible only on


and only for authenticated user role.

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.