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->display_handler->display->display_options['filters']['usershare']['value'] = 'admin';

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

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, privacy policy and cookie policy

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