How to Disable Profile2 Field Elements I would like to disable some form elements within a Profile2 form in Drupal 7 (ie still visible but not editable). I figured using hook_form_alter would be the way to go but I can't figure out where I need to set the ['disabled'] field to true.

Here is the code that I have:

$fields = field_info_instances('profile2', 'student')
if ($fields) {
  foreach($fields as $field) {
    $field['#disabled'] = true; &lt;- don't know what attribute to set here
  }
}


In Drupal 6 this seemed pretty straight forward but using dsm($field) is not helping me determine what field attributes need to be set. I have Googled this and looked at the Drupal 7 API and I am still lost.

I am hoping someone can help me out here.

Thanks.
In drupal 7. You can use the "field permissions" module + profile2 module.
In order to disable some fields for anonymous user, you just edit the fields with custom permissions.
You can see the demo of configuration page from here : 

Currently to disable some fields from profile2 for register form, I just set permissions that don't allow the anonymous user to see that fields.