• Resolved poolfactory

    (@poolfactory)


    Hi, I want to make snippets conditional, depending on which site they are running. My approach was to set a variable depending on which site they are running on. But it looks like I can’t just set a variable and read its value later because the value is not processed.

    The snippet looks like this:

    $siteID = 0;

    function whatever() {
    global $siteID;
    if ($SiteId = 0) {
    do something;
    } else {
    do something different;
    }
    return $result
    }

    Thanks for your advice ??

    • This topic was modified 9 months, 1 week ago by poolfactory.
Viewing 1 replies (of 1 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    I recommend using a constant for this, instead of a variable:

    const SITE_ID = 0;

    Put this in a snippet with a high priority (low number), e.g. 0.

    You should be able to then reference it in subsequent snippets:

    if ( SITE_ID === 0 ) {
        // do something
    } else {
        // do something different
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Define variable and read its value’ is closed to new replies.