how hide ( input ) fields in node / ad (content type )form

Hello all ,

I have a content type with some fields ,

How can I hide a particular  fields based on a user’s role when they use node / add /contenttype .I looked around for code and I made a module and I put my code in the module , but it doesn’t work , the site becomes unreachable .

Here is what I have , I don’t know to put it all in the right order , if anyone can help me out thanks forever ..

I used this to try to find out if a use is member of a role :

$user = user_load(array(‘uid’ => $node->uid));
  foreach ($user->roles as $rid => $role) {
    if ($role == ‘basic_node_users’) {

en this to check the id of the form I wish to alter , en where it all goes more wrong I guess

function mymodulename_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == ‘mycontentnodeadd_node_form’) {
   hide( $form[‘my_field_name’]);
  } }

anyone who is willing to put it is the correct order etc ?

Drupal version: 


Source: https://www.drupal.org/taxonomy/term/4/feed