I want to show a block when a user visits his/her own profile page at /user. The public user profiles have paths of "/member/[username]".

When I limit the block to "user" it won't show up. When I limit it to "member/*" it will show up both on the own profile and on the public profiles.

Is the "user" url something special?

  • 2
    It also works for "user/*" which makes me think the internal alias for the user page is actually user/[uid]...might have to resort to PHP for this one :/
    – Clive
    Jul 12, 2012 at 17:09
  • 7
    return arg(0) == 'user' && is_numeric(arg(1)) && !arg(2); will do the trick
    – Clive
    Jul 12, 2012 at 17:17
  • 1
    @Clive As usual dropping the FIRE in comments =D Jul 12, 2012 at 18:57
  • @Clive, just wanted to give you further props for this answer. One year later, and I found this page again. Thanks again!
    – hockey2112
    Jun 11, 2014 at 14:44

1 Answer 1


What @clive has mentioned is great if you want to use /user for this, but from a number of angles, I really don't like using it at all for this kind of thing. I would like to say mostly from a style perspective, but actually more from a linking perspective, eg, an email or post that includes check out my cool profile on mototribe: www.mototribe.com/user bollixing things up.

So, when I've done stuff like this, I include php logic in my block view along the lines of:

$global $user;

if ($node->type==THENODETYPEWEARELOOKINGFOR && $node->uid==$user->uid) {
  // generate the block here
} else {
  // don't generate anything (or put something else in it's place)

return $block;

so the block is only generated when the currently logged in user looks at a certain node type that s/he owns. Obviously I've not fleshed out all the isset()s or empty()s needed in prime time for the above but I am sure you get the jist.

Of course, I could also be talking total smack here if D7 user profiles aren't nodes, but this works great in D6 with content profiles :)

  • that's a great point and a reason to not use /user. I guess I can use some PHP to check if the logged in user is looking at his/her own profile to show the extra block. Thanks
    – uwe
    Jul 13, 2012 at 1:13
  • Combination of yours and Clive's code: global $user; return arg(0) == 'user' && is_numeric(arg(1)) && !arg(2) && $user->uid == arg(1); Thanks again!!!
    – uwe
    Jul 14, 2012 at 1:29

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.