0

I have the following view being called in my code with views_get_view() and I then try to modify the filter called usershare to admin instead of the default that I have set in my view. But it doesn't seem to override my view output. What am I doing wrong here? I noticed that some examples use pre_execute() and some just use excute(). I'm not sure if that has anything to do with it.

      $view2 = views_get_view('flag_lists_user_lists_public', FALSE);
      $view2->set_display('default');

$view2->display_handler->display->display_options['filters']['usershare']['value'] = 'admin';

      $view2->pre_execute();
      $output .= $view2->render();  

1 Answer 1

0

You can use hook_form_views_exposed_form_alter() :

/**
 * Implements hook_form_views_exposed_form_alter().
 */
function MY_MODULE_form_views_exposed_form_alter(&$form, &$form_state) {
  if($form['#id'] == 'flag_lists_user_lists_public') {
    $form['usershare']['#value'] = 'admin';
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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