• Add-ons
  • Blog
  • Resources
    • Documentation
    • FAQs
    • Code snippets
    • Use cases
    • Support
  • Account
    • My account
    • Checkout
    • Cart
  • English
  • French
  • Add-ons
  • Blog
  • Resources
    • Documentation
    • FAQs
    • Code snippets
    • Use cases
    • Support
  • Account
    • My account
    • Checkout
    • Cart
  • English
  • French
home/Knowledge Base/Code snippets/Sidebars: how to disable them

Sidebars: how to disable them

631 views 0 April 13, 2021

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_disable_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_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' );
}
Tags:sidebar

Was this helpful?

Yes  2 No
Related Articles
  • Custom admin notification’s recipients
  • Disable CSS resets and allow integration of third party plugins
  • Automatically add a user to a group
  • Changing the default page shown by the Customer Area
  • Changing the page shown after logout
  • Detect if you are on a page in the customer area

Didn't find your answer? Contact Us

Knowledge base
  • Code snippets 25
  • Use cases 2
  • Community links 5
FAQ
  • About licences 7
  • Pre-sales questions 3
  • After-sales questions 1
  • Plugin usage 8
  • Technical questions 10
  • Payments 4
Documentations
  • Getting started
  • Using code snippets
  • The template system
  • Full documentation
Support
  • Pre-sales Enquiries
  • Main plugin support
  • Premium add-ons support
  • Feature Requests

  Detect if you are on a page in the customer area

Changing the page shown after logout  

  • Terms and conditions for sales
  • Refund policy
  • Privacy Policy
  • Legal notices
  • Copyright 2021 wp-customerarea.com. All Rights Reserved.