By paul555 on
Hi all. I have made a block with the following sample code i found.
<?php
global $user;
$myuid = $user->uid;
$node = content_profile_load(profile, $myuid);
$profileid = $node->nid;
?>
<?php print l("My profile","user/".$user->uid."/profile"); ?>
<br /><?php print l("Edit my profile","user/".$user->uid."/edit/profile"); ?>
<br /><?php print l("Contact me","user/".$user->uid."/contact"); ?>
<br /><?php print l("My photos","galleries/".$user->uid); ?>
<br /><?php print l("My friends","relationships/list"); ?>
<br /><?php print l("My private messages","messages"); ?>Now i want to ask how can i make this block to appear only if the user viewing the profile page is the logged in user. Thanks in advance.
Comments
.:
1) Go to Administration -> Blocks.
2) Select "Configure" link next to the name of the block that you want to set visible only for logged in users.
3) Choose 'authenticated user' under 'Role specific visibility settings'
------------
Volvo, Video, Velcro. (I came, I saw, I stuck around.)
The logged in user?
I don't really understand your question. The $user object contains the information for the currently logged in user. So the code you have will create links that append that users' id on the end. As long as the pages you are linking to are sensitive to the user id then they will only show information based on the currently logged in user.
You should be able to set your block to only display to "authenticated" users, thereby hiding it from "anonymous" users.
I am sorry but i didn't
I am sorry but i didn't explain well my question. I don't know anything about php and Drupal API. My goal i want to achieve is the following. When a user logs in my site and go to his profile page then the block will show up. Any other user authenticated or not will not be able to see this block. Also a similar question i want to make is can i change my photos link to something like "username's" photos?
I forget to mention that i created this block and then i placed it in the /user/%user system page.
For others...
Others looking for a way to do this. I believe the answer is here:
https://drupal.org/node/134433
Some php that goes in the block's page visibility box