How to delete a view programatically?
It's crazy I can't find proper answer for such a simple question.
How to delete a view programatically?
It's crazy I can't find proper answer for such a simple question.
Views has a function in it called views_delete_view, it takes a view object as a param. Try views_delete_view($yourloaded_view), that should do the trick.
Give a try to the following code to delete the view:
// Check the view id the one that you are looking for.
if ($view = views_get_view($name)) {
// Delete the view if it is the one that you are looking for.
views_delete_view($view);
}
views_delete_view
. This answer is way more elaborate than necessary: views_delete_view
calls $view->delete();
and then the delete
method does the cache invalidation.
– user49
Sep 23 '14 at 18:51
$view->delete();
, if required you may check the answer now.
– Ankit Agrawal
Sep 23 '14 at 19:03
views_view::delete()
– Clive♦ Sep 23 '14 at 15:06