title: How can I pass a variable to spreadsheet function?
body: <p><strong>Here is what I'm trying to do:</strong></p>
  
  <p>Embed a Google spreadsheet in my website in multiple locations. For registered users, I want to show all the data in the spreadsheet. For unregistered users, I want to hide key numbers.</p>
  
  <p>I have a spreadsheet with a custom function called blackOut(). I've put the blackOut function in all of the cells with sensitive data. All blackOut() need to do is this:</p>
  
  <pre><code>function blackOut(e) {
    var is registered = ??
    if (is_registered) return e;
    else return "";
  }
  </code></pre>
  
  <p>But I cant find any way to 'pass' any variables from my website to the function, so I haven't been able to make it work.</p>
  
  <p><strong>Here's my environment:</strong></p>
  
  <p>In PHP I'm using cURL to get the spreadsheet's embed code from this URL:</p>
  
  <p><a href="https://docs.google.com/spreadsheet/pub?key=[spreadsheet" rel="nofollow noreferrer">https://docs.google.com/spreadsheet/pub?key=[spreadsheet</a> ID]&amp;output=html&amp;widget=true</p>
  
  <p>then I'm doing a few str_replace functions to make the JS and CSS work.</p>
  
  <p><strong>Here's what I've tried:</strong></p>
  
  <ul>
  <li>using window.location in my function (doesn't work. Google doesn't let you access window)</li>
  <li>passing a javascript variable in globally (in JS global variables are technically attached to the window object)</li>
  <li>using SpreadsheetApp.getActiveSpreadsheet().getURL() (just returns the URL for the spreadsheet, not the one that existed in the http request)</li>
  <li>looking through all of the available objects in Google Code</li>
  </ul>
  
  <p><strong>My Ideal Solution:</strong></p>
  
  <p>It would be great if I could just add '&amp;blackout=true' to the URL, and pass that into blackOut() in the google script. I've looked around a lot, and I don't think it's possible.</p>
  
  <p><strong>I've looked at these links:</strong></p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/17434309/getting-url-parameters-in-google-apps-script">How can I get URL parameters passed to a Google Spreadsheet using Google Apps Script?</a></li>
  <li><a href="https://stackoverflow.com/questions/20062564/alternative-to-global-variables">Alternative to global variables</a></li>
  <li><a href="https://stackoverflow.com/questions/12106723/gas-problems-in-using-global-variables-in-functions">GAS: Problems in using global variables in functions</a></li>
  </ul>
  
  <p>Any ideas on how I can get this to work?</p>