hook_field_extra_fields() are enabled by default on all content types

So what? Just use the following code in your hook_install() function to disable it in every content type and in every view mode available in your website. Or if you are working on a custom module and you only want to execute this once, use Devel's "devel/php" page and paste it there!
$field_name = 'THE_MACHINE_NAME_OF_YOUR_CUSTON_FIELD';
$types = array_keys(node_type_get_types());
foreach($types as $bundle) {
  $entity_type = 'node';
  $field_bundle_settings = variable_get("field_bundle_settings_{$entity_type}__{$bundle}", array());
  $view_modes = field_view_mode_settings($entity_type, $bundle);
  foreach($view_modes as $view_mode => $data) {
    if($data['custom_settings'] == TRUE) {
      $field_bundle_settings['extra_fields']['display'][$field_name][$view_mode]['visible'] = FALSE;
    }
  }
  variable_set("field_bundle_settings_{$entity_type}__{$bundle}", $field_bundle_settings);
}

Comments

Popular Posts