Title: Filter locked users
Last modified: October 30, 2016

---

# Filter locked users

 *  [DeBAAT](https://wordpress.org/support/users/debaat/)
 * (@debaat)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/filter-locked-users/)
 * Hai,
    First thanks for the plugin, I’m using it for a membership web-site. And
   it is working fine. For some management function, I lock a user when it doesn’t
   match the requirements for membership any more. With about a thousand members,
   the list of users is very long, and only some are locked at any time. Now, would
   it be possible to add a filter to the list of users showing only the locked users?
 * Best,
    Jan

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [DeBAAT](https://wordpress.org/support/users/debaat/)
 * (@debaat)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/filter-locked-users/#post-8380274)
 * Hai,
    In case you are interested, I’ve tried to implement it myself using the
   code below. Hope you can improve this in a next version of this plugin. Thanks.
   Jan
 *     ```
       <?php
   
       // Actions and filters to filter the users
       add_action('restrict_manage_users',          array($this, 'vyn_restrict_manage_users')             );
       add_filter('users_list_table_query_args',    array($this, 'vyn_users_list_table_query_args')       );
   
       /**
        * Filter the list of users for locked users only
        *
        * @param string $which Whether this is being invoked above ("top")
        *                      or below the table ("bottom").
        */
       function vyn_restrict_manage_users( $which ) {
       	$id = 'bottom' === $which ? 'new_filter2' : 'new_filter';
   
       	// Check whether to filter or not
       	$filter_users = '';
       	if ( isset( $_REQUEST['new_filter'] ) && $_REQUEST['new_filter'] == 'vyn_locked_user' ) {
       		$filter_users = 'selected="selected"';
       	}
       	if ( isset( $_REQUEST['new_filter2'] ) && $_REQUEST['new_filter2'] == 'vyn_locked_user' ) {
       		$filter_users = 'selected="selected"';
       	}
       	?>
       	</div>
       	<div class="alignleft actions">
       		<label class="screen-reader-text" for="<?php echo $id ?>"><?php _e( 'Filter user&hellip;', 'vyn' ) ?></label>
       		<select name="<?php echo $id ?>" id="<?php echo $id ?>">
       			<option value=""><?php _e( 'Filter user&hellip;', 'vyn' ) ?></option>
       			<option value="vyn_locked_user" <?php echo $filter_users ?>><?php _e( 'Locked users', 'vyn' ) ?></option>
       		</select>
       	<?php
   
       	submit_button( __( 'Filter', 'vyn' ), 'button', 'vyn_filter_locked', false );
   
       }
   
       /**
        * Filter the list of users for locked users only
        *
        */
       function vyn_users_list_table_query_args( $query_args ) {
   
       	// Check whether to filter or not
       	$filter_users = false;
       	if ( isset( $_REQUEST['new_filter'] ) && $_REQUEST['new_filter'] == 'vyn_locked_user' ) {
       		$filter_users = true;
       	}
       	if ( isset( $_REQUEST['new_filter2'] ) && $_REQUEST['new_filter2'] == 'vyn_locked_user' ) {
       		$filter_users = true;
       	}
   
       	// If filter_users is requested, add query_args to filter
       	if ($filter_users) {
       		if ( empty( $query_args['orderby'] ) ) $query_args['orderby'] = 'ID';
       		if ( empty( $query_args['order']   ) ) $query_args['order'] = 'ASC';
       		$query_args['meta_key'] = 'theme_my_login_security';
       		$query_args['meta_value'] = ';b:1;';
       		$query_args['meta_compare'] = 'LIKE';
       		//$query_args['meta_key'] = 'admin_color';
       		//$query_args['meta_value'] = 'clas';
       	}
   
       	return $query_args;
       }
       ```
   
 *  Plugin Author [Jeff Farthing](https://wordpress.org/support/users/jfarthing84/)
 * (@jfarthing84)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/filter-locked-users/#post-8397496)
 * Thanks for your feedback. This is an idea to be considered.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Filter locked users’ is closed to new replies.

 * ![](https://ps.w.org/theme-my-login/assets/icon-256x256.png?rev=1891232)
 * [Theme My Login](https://wordpress.org/plugins/theme-my-login/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/theme-my-login/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/theme-my-login/)
 * [Active Topics](https://wordpress.org/support/plugin/theme-my-login/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/theme-my-login/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/theme-my-login/reviews/)

## Tags

 * [filter](https://wordpress.org/support/topic-tag/filter/)
 * [lock](https://wordpress.org/support/topic-tag/lock/)
 * [user](https://wordpress.org/support/topic-tag/user/)

 * 2 replies
 * 2 participants
 * Last reply from: [Jeff Farthing](https://wordpress.org/support/users/jfarthing84/)
 * Last activity: [9 years, 6 months ago](https://wordpress.org/support/topic/filter-locked-users/#post-8397496)
 * Status: not a support question