How do I redirect the "No Result" search page to Add node? I would like to redirect the "No result found" page of the drupal search to Add node. Basically I want when users search for an item using the search text box they get redirected to the Add node page when the item is not found.
I was really hoping that _preprocess_search_results(&amp;$vars) would work, but it only gets called when there are results, so, here are two really really I can't believe I am suggesting these but they should work ways:

Drupal 6:

In your theme's template.php file, you can retheme box, which is how drupal 6 creates the 'no results found' info:

function YOURTHEMENAME_box($title, $content, $region = 'main') {

  if ($title==t('Your search yielded no results')) { 
    drupal_goto('node/add'); 
  } else {
    $output = '&lt;h2 class="title"&gt;'. $title .'&lt;/h2&gt;&lt;div&gt;'. $content .'&lt;/div&gt;';
    return $output;      
  }
}


If Drupal 7:

Copy search-results.tpl.php from the search module's directory to your theme directory and change it:

&lt;?php if ($search_results): ?&gt;
  &lt;h2&gt;&lt;?php print t('Search results');?&gt;&lt;/h2&gt;
  &lt;ol class="search-results &lt;?php print $module; ?&gt;-results"&gt;
    &lt;?php print $search_results; ?&gt;
  &lt;/ol&gt;
  &lt;?php print $pager; ?&gt;
&lt;?php else: ?&gt;
  &lt;?php drupal_goto('node/add'); ?&gt;
&lt;?php endif; ?&gt;