Show block only in user own page and for administrator role users What I'm trying to achieve:


User can see block only on his own "user/[uid]/my-page" - he cant see that block on other users my-page.
Users who belong to administrator role can see user block on user own page.


Right now my code shows block for user himself and also to administrator role users BUT for administrator role users it shows block on every page - not only in "my-page".

How to modify code to show block only in "my-page" also for administrator role users?

Here is the code:

&lt;?php
global $user;
if (in_array('administrator', ($user-&gt;roles))) {
return TRUE;
}
if (arg(0) == 'user' &amp;&amp; $user-&gt;uid == arg(1) &amp;&amp; arg(2) == "my-page" ) {
return TRUE;
}   
else {
return FALSE;
}
?&gt;


I used this code as a base: https://drupal.org/node/134433
This is almost a replica of your code with a small change. I hope it helps.


If you want to allow the admin to see the block on every other user profile page

global $user;
if (arg(0) == 'user' &amp;&amp; ($user-&gt;uid == arg(1) || in_array('administrator', ($user-&gt;roles))) &amp;&amp; arg(2) == "my-isn10") {
  return TRUE;
}
else {
  return FALSE;
}

If admin or normal user do not have a difference both can see only on their profile page.

global $user;
if (arg(0) == 'user' &amp;&amp; $user-&gt;uid == arg(1) &amp;&amp; arg(2) == "my-page" ) {
  return TRUE;
}   
else {
  return FALSE;
}