Hi,

Is it possible to just disable the "advanced search" without messing with the search module, which btw consists of 1300 lines of code DUH. Well that's great but it certainly takes time to find the right code block in there. If there is an easier solution, I'd be thankful to get to know about it, else I will have to sift through the lines of the core search module, copy it and then modify it...

Thanks in advance

Comments

nedjo’s picture

...to make advanced search a permission like it is in 5.0 (untested):


/**
 * Implementation of hook_help().
 */
function searchsimple_help($section) {
  switch ($section) {
    case 'admin/modules#description':
      return t('Provides the ability to hide advanced search by role.');
  }
}

function searchsimple_perm() {
  return array('use advanced search');
}

function searchsimple_form_alter($form_id, &$form) {
  if ($form_id == 'search_form' && arg(1) == 'node' && !user_access('use advanced search')) {
    unset($form['advanced']);
  }
}

HallSL’s picture

Hi, this is new to me... can you tell me a bit more about how to use this custom module. Is this the entire module? How do I use this code? Thanks.

nedjo’s picture

1. Save the file as searchsimple.module.
2. Place the file on your website under modules/searchsimple and enable the module.

groklem’s picture

Or you can comment out "Advanced node search form" in node.module.
Could well mess things up left right and center.
Will let you know how it goes...

ymcp’s picture

The search config module does exactly what you want.

Install, click "disable advanced search", and that's it. :-)

reggie75’s picture

this module is totally what i was looking for!

it ROCKS!!

johnbarclay’s picture

In drupal 6, just turn off permissions to "use advanced search"
/admin/user/permissions

sopovic’s picture

"In drupal 6, just turn off permissions to "use advanced search"
/admin/user/permissions"

This works in Drupal 7 also.

andrew.deering’s picture

I know this is an old thread, but this is what came up for me when searching for how to remove advanced search from the core search form.

Using an unset causes PHP notices, so rather than unset $form['advanced'], just remove access like so:

function mytheme_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'search_form' && arg(0) == 'search') {
    $form['advanced']['#access'] = FALSE;
  }
}