I have granted access for editing the main profile as a whole earlier. However, there are some fields later on requested to be disabled for certain role. Since there's no way I can set permission for individual field, I am using hook_form_alter to disable certain fields using the following code:
function mytheme_form_profile2_edit_main_form_alter(&$form, $form_state) {
global $user;
dpm($form);
if (in_array('member', array_values($user->roles))){
$form['profile_main']['field_full_name'][LANGUAGE_NONE][0]['value']['#disabled'] = TRUE;
}The code above managed to disable a text field. But I wonder how I can disable for "List (text) - Check boxes/radio buttons" e.g a Gender. And also for a date field using "Date (Unix timestamp) - widget : Pop-up calendar". I can't really find useful variables with dpm() or devel. Please advise. Thanks