• Resolved Anonymous User 13711045

    (@anonymized-13711045)


    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

    (@gripgrip)

    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.

    Thread Starter Anonymous User 13711045

    (@anonymized-13711045)

    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

    (@gripgrip)

    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)

    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.