How to remove "Users" tab from search form.

skinnydog - November 23, 2007 - 00:21

How do I remove the "users" search tab displayed on the search results page. I do not want people to search users.

-scott

=-=

VeryMisunderstood - November 23, 2007 - 00:32

even if you remove the tab someone can point to yoursite.com/search/user

I believe you will have to create a custom search.tpl.php, information is available in the handbooks -> theme development section

Try this...

Keeling - November 23, 2007 - 05:32

1. See this link here for how to strip unwanted tabs
2. Use Taxonomy Access to prevent users from pointing to yoursite.com/search/user

Good luck!

www.keelingdesign.com

thanks

skinnydog - November 23, 2007 - 17:39

thanks that worked great.

D5: don't grant "access user profiles"

xurizaemon - June 11, 2008 - 03:54

Note that this tab only appears if you have "access user profiles" permission. You may only be seeing this tab because you're logged in as an administrator, or because the current role has been granted that permission.

This UI is added by user.module using hook_search()

<?phpfunction

himagarwal - July 22, 2008 - 11:22

<?php
function _phptemplate_variables($hook, $vars = array()) {

  if(
$hook == 'page') {
   
yourthemename_removetab('address book', $vars);
   
// add additional lines here to remove other tabs
 
}

  return
$vars;
}

function
yourthemename_removetab($label, &$vars) {
 
$tabs = explode("\n", $vars['tabs']);
 
$vars['tabs'] = '';

  foreach(
$tabs as $tab) {
    if(
strpos($tab, '>' . $label . '<') === FALSE) {
     
$vars['tabs'] .= $tab . "\n";
    }
  }
}
?>

How to use it to remove the users tab from search? I tried copying and chaning the yourthemename to my theme name and replaced "address book" with "users" but it didn't worked? Did I missed something?

You can also try this

giorgio79 - October 3, 2008 - 04:41

great

phpsharma - October 3, 2008 - 04:43

solved my issue.
sharma chelluri

You can 'hide' the search

ktleow - October 5, 2008 - 09:51

You can 'hide' the search users tab using only CSS.
display: none;

-----
http://kahthong.com - A blog, portfolio & personal site
My blog is proudly powered by Drupal

Oh really? and wich class or

mortenson - November 10, 2008 - 20:58

Oh really? and wich class or id would you use?

Even tho you remove user

WoozyDuck - February 2, 2009 - 17:34

Even tho you remove user tab, the actual page would be accessible by typing "search/user"
So if you really want to remove user search from your website, you need to disable the "user_search" function in your "user" module.
In order to do this, open user.module file and find function user_search($op = 'search', $keys = NULL) and either remove or disable it.
In this case, search will not find user's search hook and will not add any tab nor any search result for users.

After every update you must

jasom - February 8, 2009 - 11:04

After every update you must do it again. Better is some nice template.php solution:)

Fixing this at the module level

rohnjeynolds - July 6, 2009 - 19:31

I got results in Drupal 6 using hook_menu_alter(). This removes not only the tab but the Drupal path to user search, which is what I really needed. If this is bad, I'm sure someone will point out why, but I feel that this issue is best solved at the module/menu level rather than the theme level.

function mymodule_menu_alter(&$items) {
    unset($items['search/user/%menu_tail']);
}

Removed the tabs, but not the url to user search

nrackleff - August 27, 2009 - 21:56

I just built a little helper module using the following code as suggested above.

function disable_user_search_menu_alter(&$items) {
    unset($items['search/user/%menu_tail']);
    unset($items['search/profile/%menu_tail']);
}

While it did remove the tabs from the search page, it did not remove the ability to search users or profiles. For example, I can still go to '/search/user/deanna' and return results with a list of users named 'deanna'.

Any ideas?

Thanks,
Nancy

Maybe you can use something

ressa - November 5, 2009 - 15:46

Maybe you can use something like

  unset($items['search/user/%user/example']);

From here: http://drupal.org/node/483324

 
 

Drupal is a registered trademark of Dries Buytaert.