Delete Drupal View programatically

Quick function to delete a view.

This is basically what the UI form submit does.

<?php
function delete_view($name) {

   
$view = views_ui_cache_load($name);
   
$view->delete();
   
views_object_cache_clear('view', $view->name);

}
?>

Tags

Post new comment

Got something to add - just enter a comment
all other fields are optional.

Your email address will not be published.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.