views:

342

answers:

2

I have been using hook_alter to modify forms in a custom PHP module. I started to take the same approach modifying the result page of "node add" form. However this page is not a form so I don't have a form ID to hook on to. Actually it contains a login form, but that does not contain the elements that I am looking for.

Next I cloned the node.tpl.php file called and called it node-my-content-type.tpl.php. If I add "hello world" to this page, the phrase is displayed at the top, so I know it is working.

However, here all my content seems to be flattened to a single string called $content, so manipulating this becomes very difficult.

What approach should I use in this situation?

+1  A: 

You can determine properties of the current user by doing:

global $user;
var_dump($user);

That will show you your account. So if you want to limit something by role, you would do:

if (in_array('administrator', $user->roles)) {
  // code
}

But I think you would be much better suited to using CCK and Content Permissions to control field level visibility like this.

Kevin
both are great answers!
bert
A: 

The default admin account always has the uid of 1 in the users table, so to do something for everyone except the admin, you could do this:

// Bring the $user object into scope
global $user;

if ($user->uid != 1) {
  do something here...
}
flamingLogos