Last updated December 29, 2011. Created by add1sun on April 7, 2007.
Edited by hedley, bekasu. Log in to edit this page.
On profile pages, if the user is viewing his/her own page they see their Private message block, group block, etc. (basically all of their personal blocks), but if they are viewing a DIFFERENT user profile, I do not want them to see those details (as I don't want to see a list of my messages/groups/etc. on someone else's page).
<?php
global $user;
if (arg(0) == 'user' && $user->uid == arg(1)){
return TRUE;
}
else {
return FALSE;
}
?>http://www.example.com/user/uid
http://www.example.com/arg(0)/arg(1)
So basically the block is visible if the viewer's uid is the same as arg(1) meaning the viewer is viewing his/her own profile.
Show Block on Profile Page Only
If you want to show a block on only the profile page and not any user tabs such as user/1/edit, etc., you need to include another conditional. Change this line:
if (arg(0) == 'user' && $user->uid == arg(1)){To this:
if (arg(0) == 'user' && $user->uid == arg(1) && arg(2) == '' ){
Comments
not working
not working for drupal 6.20
update: I was doing mistake with missed <?php opening and closing
I ♥ Drupal.
Works for me, using Drupal
Works for me, using Drupal 6.20.
This also works for Drupal 7
This also works for Drupal 7