I've searched for a Views snippet to do just this but haven't found any ...

I have several user-specific Views (image gallery, blog, buddylist, etc.). I would like to include a link in the header or footer to, for example, "Click here to post a new blog". I can easily include a link now but I would like for the link to only display if the person viewing the page is actually the owner of the information. It doesn't make sense for a user to be viewing another user's gallery and have to see "Click here to upload a picture to your gallery".

Any suggestions?

Comments

cmsproducer’s picture

$node->uid refers to the UID of the node creator
global $user->uid is the UID of the current user

So you can compare these two values and create a conditional that will determine if the node author is the same as the current viewer.

global
$current_user = $user->uid;
$node_author = $node->uid;
if ($current_user == $node_author)
{print "post blog entry"};
else {print "this is not your blog"};

-----
iDonny Productions: Drupal CMS Implementation, Theme UI/UX Design & Development, and Web Standards

WISEOZ’s picture

Thanks for responding iDonny. I was getting lonely.