/** * This adds a custom query that can be used in the Users > All Users filtered views. * * Set the variables according to comments noted in the snippet. You will need to * set values for the $view_name (a unique slug), $meta_key, and $meta_value as * noted below. */ add_filter( 'wpmem_query_where', function( $query_where, $show ) { // Set these accordingly: // The view name: $view_name = 'my_unique_view_name'; // The meta key of the field you are filtering by: $meta_key = 'my_field_meta_key'; // The value of the field you want to filter by: $meta_value = 'the field value'; // Don't change this: $query_where = wpmem_add_query_where( $query_where, $view_name, $meta_key, $meta_value ); return $query_where; }, 10, 2 ); /** * This adds the link for the custom query you created above. * * Similar to the snippet above, you'll need to set the variable values * to be used. Note that some of them need to be the same as what you * set in the above snippet (the field name and value and the filter name). */ add_filter( 'wpmem_views_users', function( $views, $show ) { // Displayed value of your filter link in Users > All Users $name = "My Filter View"; // Custom view name (should match $view_name used above) $view_name = "my_unique_view_name"; // The meta key of the field you are filtering by (should // match what you're using above, this is for the count) $meta_key = 'my_field_meta_key'; // The value of the field you want to filter by (should // match what you're using above, this is for the count) $meta_value = 'the field value'; // Don't change this: $views = wpmem_add_user_view_link( $views, $name, $view_name, $meta_key, $meta_value ); return $views; }, 10, 2 );
Not sure what to do with this code?
You're not a "coder" and don't know what to do? Don't worry! Code Snippets are the basic building blocks of WordPress customization, and once you know the basics, they are simple to use.
Here are some free articles to get you started:
- Using Code Snippets from the Site
- Using a code snippets plugin
- The functions.php File
- Create a plugin file for custom functions
- Create a child theme
- Do not modify plugin files!
For "hands on" help, consider a plugin support subscription or the Pro Bundle.