Opened 5 years ago
Closed 5 years ago
#37485 closed defect (bug) (duplicate)
Custom filter in users list
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Users | Keywords: | |
Focuses: | Cc: |
Description
I have example code:
<?php function admin_users_filter( $query ){ global $pagenow,$wp_query; if ( is_admin() && $pagenow=='users.php' && isset($_GET['abc']) && $_GET['abc'] != '') { $query->search_term = urldecode($_GET['abc']); global $wpdb; if (!is_null($query->search_term)) { $query->query_from .= " INNER JOIN {$wpdb->usermeta} ON " . "{$wpdb->users}.ID={$wpdb->usermeta}.user_id AND " . "{$wpdb->usermeta}.meta_key='meta_key_name_here' AND "."{$wpdb->usermeta}.meta_value LIKE '%{$query->search_term}%'"; } } } add_filter( 'pre_user_query', 'admin_users_filter' ); add_action( 'restrict_manage_users', 'restrict_abc_manage_list' ); function restrict_abc_manage_list() { ?> <select name="abc" style="float: none;"> <option value=""><?php _e('Filter By College', 'baapf'); ?></option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> <input id="post-query-submit" class="button" type="submit" value="Filter" name=""> <?php }
Source: http://stackoverflow.com/a/20520947
But variable "abc" have empty value. WTF?
Change History (2)
Note: See
TracTickets for help on using
tickets.
Duplicate of #35307.
That's because the select box is added to the bottom of the table too. On a form submit the value of the first select box gets overridden by the value of the second box. [37422] introduces the
$which
parameter so you can use two different name attributes.Related: [bbpress6061]