I have two blocks created by my module via hook_block. I also have additional user profile fields set as category "employee". In the hook, I set the visibility to:

user/*
user/*/edit/employee

...but it doesn't seem to make any difference. These two blocks show on ALL user pages, including "user/*/edit" (edit the basic account information). As a test, I left Block 1 as the above settings and changed Block 2 to:

user/*/edit
user/*/edit/employee

Both blocks still show on ALL user pages. From working with access permissions, I know the logic surrounding user pages seems to be a bit unusual, so I'm wondering if that could be causing this issue as well. Has anyone else encountered a situation like this?

Comments

hbergin’s picture

To see if your issue is with your hook, it might be worth trying out your filters on a standard block as a test?

e.g. if you create a block in the admin interface and apply your visibility filters, do they work as you would like?

extexan’s picture

@hbergin, good suggestion. I tried that on the "Powered by Drupal" block and saw the same results. In fact, for *that* block, I put only user/*, yet it showed on all these pages:

user/*
user/*/edit
user/*/employee
user/*/devel   <-- I hadn't tried this one before 

The issues I alluded to regarding access functions for the user pages were similar to this. Specifically, I had a my_module_user_access function set ONLY for user/*/edit/employee, but it was firing on ALL user pages. That's why I think there's something strange going on with the user pages that is circumventing the usual Drupal behavior.

It's never too late to have a happy childhood. ;-)

bappa.sarkar’s picture

Use PHP code instead for visibility. See in block configure Visibility settings "Pages on which this PHP code returns TRUE (experts only)"

user/* covers user/*/*, user/*/*/* ...

hbergin’s picture

as bappa.sarkar says, user/* will make the block show up on any page with user/ at the beginning of the path. The * is a wildcard for any pattern that comes after user/.

if you only include: user/*/edit, what happens?

extexan’s picture

Hmmmmm... I thought each "level" would have to be specified - that is, if I wanted user plus *anything* plus *anything* I would have to specify user/*/*.

If what you're saying is true, how would it ever be possible to have a block on user/* but not user/*/{anything else} ? That approach forces people into using php code for visibility, which is explicitly stated to be for "experts only". I'd point out that not everyone who uses Drupal is an "expert" (or even proficient in php).

Anyway, thanks for the answers.

It's never too late to have a happy childhood. ;-)