0

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:

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

0

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.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.