Im trying to get a block to only show on users accounts. But whenever I put to show only on user/* under block visability settings it shows up on all user pages, such as user/*/edit and user/*/contact.

I just want the block on user accounts. Im guessing I nee dto put some php in, but I have no idea what :(

Thanks for any advice.

Comments

j_ten_man’s picture

  $args = arg();
  if (count($args) > 2) return FALSE;
  if (($args[0] == 'user') || ($args[0] == 'users')) {
    if (count($args) == 1) return TRUE;
    if ((($args[0] == 'user') && is_numeric($arg[1])) || ($args[0] == 'users')) {
      return TRUE;
    }
  }
  return FALSE;

You should probably check the second argument if you the path is users/username but this should be sufficient.

SamSound’s picture

ive put the code in
enabled Show if the following PHP code returns TRUE.
Saved the block, and now nothing shows up on any pages.

I go to users/exampleuser and the block just aint their. :S

j_ten_man’s picture

Oops - here is the fixed code ($arg replaced with $args in one place):

  $args = arg();
  if (count($args) > 2) return FALSE;
  if (($args[0] == 'user') || ($args[0] == 'users')) {
    if (count($args) == 1) return TRUE;
    if ((($args[0] == 'user') && is_numeric($args[1])) || ($args[0] == 'users')) {
      return TRUE;
    }
  }
  return FALSE;