Searching your Drupal site for Content by Author

Recently at work the issue came up that people were searching our site for all the posts by an author but it only returning the author’s biography node. After some digging, I finally found a simple solution thanks to Julia at

The solution was simple and worked exactly as I was hoping it would. All you have to do is add the following code to your custom module (You don’t have a custom site module?).


//Adding author name to the search index
function custom_helper_nodeapi($node, $op, $arg = 0) {
   switch ($op) {
     case 'update index':
       if ($node->uid) {
          $user = user_load(array('uid' => $node->uid));
          return $user->name;


Hopefully you find this helpful. The only drawback to this method is that you will have to trigger a reindex of all the content on the site.

Leave a Reply

Your email address will not be published. Required fields are marked *