Skip Navigation

[Resolved] View that lists custom fields for logged in user

This support ticket is created 7 years, 3 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 5 replies, has 2 voices.

Last updated by Shane 7 years, 3 months ago.

Assisted by: Shane.

Author
Posts
#556218

I'm creating a view that lists details for the current user. Some fields (user_login, for instance) will work, but I have custom user fields that I can't seem to filter by the logged in user.

If I add something like [types usermeta='my-custom-userfield'], it always shows the info for user 1.

I've also tried: [types usermeta='my-custom-userfield' users='[wpv-user field=ID]']. If I just add [wpv-user field=ID], it displays the correct user ID, but the filter doesn't work.

My Query filter will let me filter by users with an ID matching a URL parameter OR a shortcode attribute. How can I filter by logged in user?

Thanks

#556247

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi David,

Thank you for contacting our support forum.

What I would recommend doing is to set the view to filter by a shortcode parameter and use the following shortcode to filter it by the current user.
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-current-user
Please let me know if this helps.
Thanks,
Shane

#556261
options.JPG

Can you clarify how to do that? When I try to add a user filter, that is not an option.

#556267

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi David,

Yes this is to correct filter for the shortcode attribute.

So you will insert your view in the page like this.

[wpv-view name='my-view' users="[wpv-current-user info='id']"]

Please let me know if this clarifies things a bit for you.

Thanks,
Shane

#556299
referred-by-fields.JPG
front-end.JPG

I see. The attribute needs to be in the shortcode. I was using a widget to set that, which does not allow you to specify a shortcode attribute.

I'm still having some trouble with this. I have a user field, which I added with Types

but it's not showing the correct record:

[types usermeta='profession'][/types]

This field is ALWAYS showing the result from the lowest User ID.

#556560

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi David,

I see, so manually set the ID to the current user like this.

[types usermeta='profession' id="[wpv-current-user info='id']"][/types]

Please try this and let me know the results.
Thanks,
Shane