Hello,

I would like to show some button on article only to author of the post.

Is it possible to do something like this?

Thank you!

Comments

karschsp’s picture

It's definitely possible. In your theme's template.php you could do:

function yourthemename_preprocess_node(&$variables) {
  global $user;
  if ($variables['uid'] == $user->uid) {
    $variables['is_author'] == TRUE;
  }
}

Then in your node.tpl.php, you can put:

if (isset($is_author) && $is_author) {
  // Insert button here
}
gjangelo’s picture

in the article template, you can write some php to compare the values of the logged in user and the node's author

some thing like this....

global $user;
if ($user->uid == $node->uid) {print "hey you are the article's author";} else {print "some one else wrote this one.";}

Just replace my output text with the code for your button.

WEBstar’s picture

This is really great! Thank you guys! I appreciate it!