Skip to content

Instantly share code, notes, and snippets.

@mordonez
Created October 17, 2013 16:07
Show Gist options
  • Save mordonez/7027637 to your computer and use it in GitHub Desktop.
Save mordonez/7027637 to your computer and use it in GitHub Desktop.
Drupal 7: Delete fields and instancies
/**
* Delete fields and instancies
*/
function yourmodule_update_7002() {
$bundles = array (
'your_contentype' => array(
'field_yourfield',
),
);
foreach ($bundles as $bundle => $fields) {
foreach ($fields as $field) {
$instance = field_info_instance('node', $field, $bundle);
field_delete_instance($instance);
}
}
foreach ($bundles as $bundle => $fields) {
foreach ($fields as $field) {
field_delete_field($field);
}
}
// Purge all field information.
field_purge_batch(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment