Title: Error Setting Variable to a Boolean Value
Last modified: July 28, 2023

---

# Error Setting Variable to a Boolean Value

 *  Resolved Anonymous User 13711045
 * (@anonymized-13711045)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/error-setting-variable-to-a-boolean-value/)
 * Does setting variables to boolean values not work in this plugin? Here’s my code:
 * `add_filter( 'do_rocket_generate_caching_files', function($filter) {
    if ( is_user_logged_in()){
   $filter = false; } return $filter;} );
 * This is causing the snippet to be deactivated and throwing this error…
 * `2023-07-28T12:45:15+00:00 Undefined variable $false`
 * `2023-07-28T12:45:15+00:00 Snippet "WP Rocket Functions" (#1100) was automatically
   deactivated due to a fatal error.`
 * What’s going on here?
    -  This topic was modified 2 years, 10 months ago by Anonymous User 13711045.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Mircea Sandu](https://wordpress.org/support/users/gripgrip/)
 * (@gripgrip)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/error-setting-variable-to-a-boolean-value/#post-16930059)
 * Hi @thekendog,
 * From the error message you included it seems like you may have had a typo there
   where you set the $filter variable to $false instead of false?
 * Otherwise, the error is not coming from this snippet and another snippet is throwing
   the error related to $false and also deactivates this one due to the way snippets
   are loaded, more details on that can be found in [this article](https://wpcode.com/docs/php-error-handling-safe-mode/).
 *  Thread Starter Anonymous User 13711045
 * (@anonymized-13711045)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/error-setting-variable-to-a-boolean-value/#post-16930066)
 * Nah, there was no typo. The same error was actually happening even if I did “
   return false;”. What I had to do was run the snippet only on the frontend. Not
   sure why, but it appears to be an issue with WPCode and running that code in 
   the backend.
 *  Plugin Author [Mircea Sandu](https://wordpress.org/support/users/gripgrip/)
 * (@gripgrip)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/error-setting-variable-to-a-boolean-value/#post-16930122)
 * Hi @thekendog,
 * From the error message you shared, the error might be related to a snippet using
   a variable $false. You can search the snippets by that variable to see if any
   of the other snippets on the site use that and create a side-effect.
 *  Thread Starter Anonymous User 13711045
 * (@anonymized-13711045)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/error-setting-variable-to-a-boolean-value/#post-16930129)
 * Jesus I am an idiot. Another snippet indeed had an error with $false instead 
   of false. That fixed the problem. Thanks for the help!
    -  This reply was modified 2 years, 10 months ago by Anonymous User 13711045.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Error Setting Variable to a Boolean Value’ is closed to new replies.

 * ![](https://ps.w.org/insert-headers-and-footers/assets/icon-256x256.png?rev=2758516)
 * [WPCode - Insert Headers and Footers + Custom Code Snippets - WordPress Code Manager](https://wordpress.org/plugins/insert-headers-and-footers/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/insert-headers-and-footers/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/insert-headers-and-footers/)
 * [Active Topics](https://wordpress.org/support/plugin/insert-headers-and-footers/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/insert-headers-and-footers/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/insert-headers-and-footers/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: Anonymous User 13711045
 * Last activity: [2 years, 10 months ago](https://wordpress.org/support/topic/error-setting-variable-to-a-boolean-value/#post-16930129)
 * Status: resolved