Sidebars: how to disable them

Some Customer Area pages allow sidebars and when those sidebars are empty, some pages display default widgets. You may want to disable sidebars altogether or to disable only default sidebars (and show them if the user manually adds a widget in there). We provide a hook to disable sidebars on a per-page basis, there is no hook to disable all sidebars.

Kindly note that unlike most of our snippets, you must create a WP plugin and include this snippet in that plugin. It will not work inside your theme functions.php because this filter is applied before your theme functions.php is loaded.

Finally, you must note that we are talking about the sidebars that are created within the private area. If you want to delete a sidebar which is provided by your theme (like the blog sidebar), you must contact your theme developer and ask them how to do that.

Fully disable a sidebar

function cuar_default_sidebar( $is_enabled ) {
  return false;
}
$page_slugs = array('customer-conversations', 'customer-private-files', 'customer-private-pages');
foreach ($page_slugs as $page_slug) {
  add_filter( 'cuar/core/page/enable-sidebar?slug=' . $page_slug, 'cuar_disable_default_sidebar' );
}

In the above code, $page_slugs is an array of all the slugs of each page on which you want to disable the default sidebar. You can find a list of all pages and their respective slugs inside the status page of Customer Area, in the “Pages” tab.

Disable only a default sidebar

function cuar_disable_default_sidebar( $is_enabled ) {
  return false;
}
$page_slugs = array('customer-conversations', 'customer-private-files', 'customer-private-pages');
foreach ($page_slugs as $page_slug) {
  add_filter( 'cuar/core/page/enable-default-sidebar?slug=' . $page_slug, 'cuar_disable_default_sidebar' );
}