hook_form_alter checking $user->uid == $node->uid I need to check if the node uid and the logged-in user's uid are identical when the user is in the node edit form, and then add a class to the form if that condition is true.* The relevant code in my custom module currently looks like this:

function custom_form_alter(&amp;$form, $form_state, $form_id) { 
    global $user;
    $node = node_load(arg(1));
    switch($form_id) {            
        case "custom_type_node_form" &amp;&amp; "$user-&gt;uid == $node-&gt;uid":
            $form['#attributes'] = array('class' =&gt; 'test-class'); 
    break;
    }
}


The class is getting added even if the user isn't the author.

*Use case is that all site members with role X can edit nodes of type Y, but if the member editing the node is the author, I'd like to add some CSS.

I'm using Drupal 6.31.
hey You can simply do this :-

function custom_form_alter(&amp;$form, $form_state, $form_id) 
 { 
    global $user;
    $node = node_load(arg(1));
    if($form_id=='custom_type_node_form')
     {
       if($user-&gt;uid == $node-&gt;uid)
        {
          $form['#attributes'] = array('class' =&gt; 'test-class');
        }
      }
}


I hope this will work for you.