Last active
February 10, 2016 10:59
-
-
Save batigolix/f8e0a3dd916f237a7383 to your computer and use it in GitHub Desktop.
Delete custom fields in Drupal 7
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 field | |
*/ | |
function mymodule_update_7000() { | |
$fields = array( | |
'field_myfield1', | |
'field_myfield2', | |
); | |
foreach ($fields as $field) { | |
if ($instance = field_info_instance('node', $field, 'page')) { | |
field_delete_instance($instance); | |
} | |
} | |
field_purge_batch(count($fields)); | |
} | |
/** | |
* Implements hook_uninstall(). | |
*/ | |
function nexteuropa_map_uninstall() { | |
$t = get_t(); | |
// Deletes the field create by this module. | |
$fields = array('map_layers'); | |
foreach ($fields as $field) { | |
if ($instance = field_info_instance('map', $field, 'map')) { | |
field_delete_instance($instance); | |
} | |
} | |
field_purge_batch(count($fields)); | |
drupal_set_message($t('Nexteuropa map has been uninstalled. Map layers field has been deleted.')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment