Created
October 17, 2013 16:07
-
-
Save mordonez/7027637 to your computer and use it in GitHub Desktop.
Drupal 7: Delete fields and instancies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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