I've made a user metagroup with a field with an image in it (profle image) I've made a view to show the images. Now I want tot filter the view on the current user / the user whois loggend in. Witch shortcode do I have to use?
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
Well - as I understand, you created the user view? If yes:
To pass the current loggedin user ID, you can use the view's filter hook: wpv_filter_user_query
Please try to add the following code to your current theme's functions.php file
OR
To "Custom Code" section offered by Toolset:
=> https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/
add_filter( 'wpv_filter_user_query', 'func_get_current_user_id', 10, 3 );
function func_get_current_user_id( $query_args, $setting,$view_id ) {
global $current_user;
if($view_id == 9999){
$query_args['include'] = $current_user->ID;
}
return $query_args;
}
Where:
- Replace 9999 with your original ID
More info:
=> https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_user_query
Thanks for the answer. I only want to see the view with the userdata for the current loggedin user. So user id = id loggedin user. What to fill in for the 9999?
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
You need to replace 9999 with your original View ID.
I overlooked what you mean by ID. I thought it was the User ID. Now with the View ID it's working like a charm!
Greetings and thanks,
Jacques