How to show a link only if a node author has a certain role I have a block with which I'm creating a menu for users

&lt;?php global $user;?&gt;
  &lt;a href="/user/&lt;?php print $user-&gt;uid; ?&gt;/ideabooks"&gt;MENU1&lt;/a&gt;
  &lt;a href="/user/&lt;?php print $user-&gt;uid; ?&gt;"&gt;MENU2&lt;/a&gt;
  &lt;a href="/user/&lt;?php print $user-&gt;uid; ?&gt;/ideas"&gt;MENU3&lt;/a&gt;


This block will only be visible on user profiles. Now I want to add another link only if the profile owner has a certain role.
So I guess I have to be able to get the node author(profile owner) and then check it's role.  

How may I do this?
You can use menu_get_object() to easily and cleanly get information on what you looking at, eg, something along these lines:

$mgo=menu_get_object('user');

if ($mgo) { // we are looking at a user

  if (in_array('CERTAIN ROLE', $mgo-&gt;roles)) {

    // do whatever

  }

}


and if the user you are looking at, eg, user/###, has a CERTAIN ROLE, then you can do whatever.

Now, from your question, I am going to go out on a limb and assume you are creating this block from the Block UI and using the PHP Filter, so I guess it would look like this:

&lt;?php $mgo=menu_get_object('user') ?&gt;
&lt;?php if ($mgo): ?&gt;
  &lt;?php if (in_array('CERTAIN ROLE', $mgo-&gt;roles)): ?&gt;
    &lt;a href="/user/&lt;?php print $mgo-&gt;uid; ?&gt;/menu4"&gt;MENU4&lt;/a&gt;
  &lt;?php endif; ?&gt;
&lt;?php endif; ?&gt;


but I would strongly urge you to consider writing a module for this as the PHP filter opens up soooo many potential holes.

Also, as @olyn has pointed out, $user points to the logged in user, not to the owner of the profile you are looking at, so you will want to look into that in your code as well for your other links, eg, $user-&gt;uid is the uid of the currently logged in user; in my code above $mgo-&gt;uid is the user id of the profile you are looking at.