I am trying to:
How can I create a search panel for a user view? Can you make the site from this post available again?
Thanks
Oliver
I visited this URL:
I expected to see:
Instead, I got:
Q1) How can I create a search panel for a user view?
I assume you are going to setup the parameter search form a in user view, there isn't such a feature with Views plugin yet, when you edit a user view, in section "Custom Search Settings", you will be able to see the message:
Only Views listing posts can have custom search inputs.
Q2) Can you make the site from this post available again?
Could you describe more details for the question?
Which site and post are we talking about? I need more details, thanks
Is there anyway to build a search panel of users in a view?
You created a test site for someone sometime ago with an example, I cannot find the link now.
As I mentioned above, there isn't such a built-in feature within Views plugin, Views is using WordPress class WP_User_Query to query users, you can setup custom filters with filter hook "wpv_filter_user_query", see our document:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_user_query
You can create your own test site in http://discover-wp.com/, but it does not support custom PHP codes.
Can you share a good example that I could build on?
I am not sure how I would use this to put a search panel at the top of my user view and how I would include multiple parameters. Can you elaborate a little?
Since there isn't such a built-in feature within Views, you will need do these manually:
1) Manually create a search form with search field and submit button, put the form into the top of your user view, when user click the submit button in front-end, it will pass specific URL parameter to the view.
2) Use filter hook "wpv_filter_user_query" to add custom filters to your views
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_user_query
I have tried the following but without any luck
function find_user_email_name( $query_args ) {
//$args = array(
//'search' => 'gmail',
//'search_columns' => array( 'user_login', 'user_email' )
//);
$query_args = array( 'role' => 'Administrator' );
if ( isset( $query_args['role'] ) ) {
unset( $query_args['role'] );
}
debug_to_console(array($query_args));
return $query_args;
}
Any suggestions?
Views is using WP_User_Query to query the wordpress users, please follow document to setup your PHP codes:
https://codex.wordpress.org/Class_Reference/WP_User_Query
For example
Search Parameters
https://codex.wordpress.org/Class_Reference/WP_User_Query#Search_Parameters
User Role Parameter
https://codex.wordpress.org/Class_Reference/WP_User_Query#User_Role_Parameter
For example:
add_filter( 'wpv_filter_user_query', 'prefix_unset_user_roles', 10, 3 );
function prefix_unset_user_roles( $query_args, $view_id, $setting) {
if ( $view_id == 123 && isset( $query_args['role'] ) ) {
unset( $query_args['role'] );
}
return $query_args;
}
Please replace 123 with your user view's ID
And how will I pass in parameter from the search section on the view page?
As I mentioned above, you will need to:
Manually create a search form with search field and submit button, put the form into the top of your user view, when user click the submit button in front-end, it will pass specific URL parameter to the view.
And here is a document about HTML form:
hidden link
If you agree, we can take it as a feature request, thanks
Great thanks, got the bones of it working. I will develop it out.
Hi,
I have a new issue where the search is being lost during paging through the details even though the values are still in the fields. How do I maintain the search fields during the paging