Skip Navigation

[Resolved] filter on currend userid / loggedin user

This support ticket is created 5 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 4 replies, has 2 voices.

Last updated by Jacques Spijkers 5 years, 5 months ago.

Assisted by: Minesh.

Author
Posts
#1256693

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?

#1256865

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

#1257309

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?

#1257775

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

You need to replace 9999 with your original View ID.

#1257841

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