Skip to content

Instantly share code, notes, and snippets.

@VladSavitsky
Created April 20, 2015 19:12
Show Gist options
  • Save VladSavitsky/0a8cdbc90544454a810c to your computer and use it in GitHub Desktop.
Save VladSavitsky/0a8cdbc90544454a810c to your computer and use it in GitHub Desktop.
Disable views page programmatically
/**
* Disable workbench views
*/
function mymodule_update_7001() {
// a list of views (their view name) I want to disable
$viewnames = array(
'workbench_current_user',
);
// grab list of views that are already disabled
$views_status = variable_get('views_defaults', array());
// add our views to be disabled to the list
foreach ($viewnames as $key => $viewname) {
$views_status[$viewname] = TRUE;
}
// reset the variable with the new list
variable_set('views_defaults', $views_status);
// empty cache now
if (function_exists('views_invalidate_cache')) {
views_invalidate_cache();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment