title: how to avoid a script on a specific page in wordpress - functions.php
body: <p>I want to deregister some styles when a user is not logged in, but not on a particular page.
  I tried adding this code into &quot;functions.php&quot; of BuddyBoss Child Theme, but on that page it seems the script is executed anyway.</p>
  <p>The script must be executed when the user is not logged in, but not in the page &quot;forums&quot;.</p>
  <p>I've already tried adding to that page critical CSS but the layout is not fine anyway, so I decided to make an exception in functions.php for the page &quot;forums&quot;.</p>
  <pre><code>add_action('wp_enqueue_scripts','my_deregister_custom',100);
  function my_deregister_custom() {
      if ( !is_user_logged_in() ) {
          wp_deregister_style('dashicons');
          if ( !is_page( array(51519,'forums'))) {
              wp_deregister_style('buddyboss-theme-forums');
              wp_deregister_style('bp-mentions-css');
              wp_deregister_style('learndash-front');
              wp_deregister_style('buddyboss-theme');
              wp_deregister_style('ldx-design-upgrade-learndash');
              wp_deregister_style('buddyboss-theme-learndash');
              wp_deregister_style('elementor-frontend');
          }
      }
  }
  </code></pre>
  <p>Here I attach a screenshot of the page edit, where you can see the page ID, the slug and the url.
  <a href="https://i.stack.imgur.com/SI2VC.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SI2VC.jpg" alt="enter image description here" /></a></p>