How to set advanced views setting in code? Specifically disabling SQL rewriting with webform_select_options So, I'm having trouble with a little custom module that places a list of flagged items in a webform with: webform_select_options_info, views, and anonymous flag. 

The issue I'm having is that the select list generated by my custom module doesn't appear for anonymous users. I suspect this has to with the issue of showing views to anonymous users by disabling SQL rewriting. I suspect this  because I'm using a view generated in code via the custom module and that the advanced settings aren't set and the function isn't being shown to anonymous users.

So, how do I set advanced options like disabling sql rewriting in code?

here's my custom function minimally adapted from drupal steve's tutorial:

&lt;?php
function webform_hook_user_flag_sample_requests() {
   $view = views_get_view('webform_flag_views', TRUE);
   $view-&gt;set_display('webform_options');
   $view-&gt;execute();
   $options = array();
   if ($view-&gt;result) {
     $row_class = $view-&gt;style_options['row_class'];
     $attributes = $row_class ? " class='$row_class'" : '';
     foreach($view-&gt;result as $item) {
       $options[$item-&gt;product_id] = '&lt;a' . $attributes . '&gt;' . render($item-&gt;field_field_image[0]['rendered']) . ' ' . $item-&gt;field_title . ' (' . $item-&gt;commerce_product_title . ')' . '&lt;/a&gt;';
     }
   }
   else {
     $options[0] = t("Nothing");
   }
   return $options;
 }
 function webform_hook_user_flag_sample_requests() {
   $view = views_get_view('webform_flag_views', TRUE);
   $view-&gt;set_display('webform_options');
   $view-&gt;execute();
   $options = array();
  foreach($view-&gt;result as $item){
      $options[$item-&gt;product_id]= $item-&gt;field_field_image[0]['rendered'];
      } 
return $options;
 }


I have a block view which shows the flags of the current user, I can confirm that each anonymous users flags work and generate unique flag lists on a per user-agent basis.

So, how do I diable sql rewriting for this view in code? or is there another reason this is happening?

Thanks
So this approach let's you edit the view through the Views UI. I thought the view was created on-the-fly by the module, but the module loaded the view into the db and exposed it to the views UI. Though this doesn't address the question directly.