DenRaf's Blog

  • Contact

Contact
View Raf Nijskens's profile on LinkedIn
OpenSource
Linux
Powered by Drupal, an open source content management system
Get Firefox
Fosdem
Visit Inuits Technical home

Locations of visitors to this page

Tags in TagCloud

6 acer ADP1 Android apache automaticmenu caching cats Centos closed source cron Debian dell Dell R200 deploy Dream driver drupal drupalcron eclair edit faceted_search fedora flat jscalendar Fosdem funambol G1 imagefield_gallery litejazz menu_tree module multiple domains mysql node_page O2Micro old openfire OSD otrs password trigger password_trigger plutado Ports presentation recover response header rpm svn sync syncml tagadelic ubuntu user filter user_import wordpress wordpress 2.3 wp2drupal xmlsitemap zabbix zimbra
more tags
Home

user filter

Create custom user filter in Drupal

Submitted by DenRaf on Tue, 06/03/2008 - 21:21
  • [View]

For a little project I needed to list all users, but not with the default user information, but with extra profile_values. Since users were not known by username, but by user id, I wanted a filter for a quick search.

In my module I recreated the form:

function messageboard_form_alter($form_id, &$form) {
if ($form_id == 'user_filter_form') {
unset($form['filters']['status']['status']); // remove status filter
unset($form['filters']['status']['permission']); // remove permission filter

$form['filters']['filter'] = array (
'#type' => 'radios',
'#options' => array (
'role' => role, // keep role filter
'uid' => uid // add my uid filter
)
);
$form['filters']['status']['uid'] = array (
'#type' => 'textfield',
'#size' => 18,
);
}
)

At first I also had the code added to fill the user_overview_filter session array with the values of the added filter, but then I got a SQL error.

At the end I saw no other way then editing the user_filters() function in the user.module like this:
$sql = db_query("SELECT uid FROM {users}");
while($row = db_fetch_array($sql)) {
$options[$row['uid']] = $row['uid'];
}
$filters['uid'] = array('title' => t('number'),
'where' => 'u.uid = %d',
'options' => $options,
);

The options are necessary if you want the text of the search displayed correctly.

I would be nice if there was some kind of hook for editing these filters. If so, please let me know. I really don't like to edit core modules.

  • DenRaf's blog
  • 6 comments
Tags:
  • drupal
  • drupal
  • user filter
Syndicate content

Guided search

Click a term to initiate a search.

Categories

  • drupal (26)
  • Linux (6)
  • SysAdmin (6)
  • Uncategorized (5)
  • Linux-tools (3)

Date authored

  • 2010 (5)
  • 2009 (10)
  • 2008 (27)
  • 2007 (11)

TagCloud

  • drupal (26)
  • Ports (7)
  • cron (6)
  • drupalcron (6)
  • 6 (3)
  • OSD (3)
  • zimbra (3)
  • cats (2)
  • Fosdem (2)
  • funambol (2)
  • more...

Recent blog posts

  • OSD2010: Day 2
  • OSD2010: Day 1
  • OSD2010: Pre notes
  • Howto: Android 2.1 on G1/ADP1/Dream
  • Updated look
  • Zimbra monitoring with zabbix
  • New module: Node Page Template
  • AutomaticMenu module for drupal 6
  • Drupal synchronisation
  • Imagefield_gallery module for drupal 6
more

Recent comments

  • Thanks for the nice blog. It
    50 weeks 4 hours ago
  • I prefer this updated
    50 weeks 4 days ago
  • Agreed.
    1 year 14 weeks ago
  • Working on this
    1 year 16 weeks ago
  • Thanx for tutorial. IT'S
    1 year 17 weeks ago
  • Amon Ra recovery tool
    1 year 20 weeks ago
  • Please help me
    1 year 25 weeks ago
  • This is so dumb
    1 year 26 weeks ago
  • I've installed it on my
    1 year 29 weeks ago
  • I am also having the same
    1 year 30 weeks ago

Syndicate

Syndicate content
I love Smashing Magazine!
Fervens Drupal theme by Leow Kah Thong. Designed by Design Disease and brought to you by Smashing Magazine.