Function preprocess_views_view if not logged in I have added two javascripts for one page only using preprosess in template.php. The two scripts seem to work well.

The jquery version I include on this page/view is interfering with admin overlay and other stuff for the editor. I'd like to apply this preprosess only if the user is not logged in.

/**
 * Equal height row javascript + jquery 1.10.2 - in page-view (my-view-page)
 */
function mytheme_preprocess_views_view(&amp;$vars) {
   $view = $vars['view'];
   // Make sure it's the correct view
  if($view-&gt;name == 'myview') {
     // add needed javascript
     drupal_add_js(drupal_get_path('theme', 'mytheme') . '/js/jquery-v1-10-2.js');
     drupal_add_js(drupal_get_path('theme', 'mytheme') .'/js/equal-height-row.js');
  }
}


Is it possible to correct this function to make sure the scripts are not served to logged in users? Or does it require a different approach like preprocess_html?

(For now there is not going to be registered users other than editors)

(Using Drupal 7.25 and custom subtheme of Responsive Bartik)
Sure, add either:

global $user;


to your function and check its uid status or wrap the drupal_add_js in an IF block using the Core API function user_is_logged_in()

For exmaple:

$user_is_not_logged_in = (user_is_logged_in() === FALSE);
if ($user_is_not_logged_in) {
  if ($view-&gt;name == 'foo') {
    /* drupal_add_js(...); */
  }
}


EDIT:

So the full thing (doing your homework for you) would look like this:

/**
 * Equal height row javascript + jquery 1.10.2 - in page-view (my-view-page)
 */
function mytheme_preprocess_views_view(&amp;$vars) {
   $view = $vars['view'];
   // Make sure it's the correct view
  if($view-&gt;name == 'myview') {
    if (!user_is_logged_in()) {
      // add needed javascript
       drupal_add_js(drupal_get_path('theme', 'mytheme') . '/js/jquery-v1-10-2.js');
       drupal_add_js(drupal_get_path('theme', 'mytheme') .'/js/equal-height-row.js');
    }
  }
}