Tuesday, March 17, 2015

Delete a field programatically from a content type



<?php

field_delete_field($field_name);
field_purge_batch();

// note: only run this if you need the field deleted immediately!! otherwise it will just be deleted the next time the cron runs

?>

If you manually delete fields from the database, many things can go wrong. For example, hook_field_delete will not be called and one of your modules might fail and crash the site.