Skip Navigation

[Resolved] Filter by [wpv-current-user info="email"]

This support ticket is created 8 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 3 replies, has 3 voices.

Last updated by Beda 8 years, 5 months ago.

Assisted by: Beda.

Author
Posts
#347370

I am trying to create a view that filters by a custom field (customer email) referencing what is returned by the existing shortcode:

[wpv-current-user info="email"]

I plan to only show only the CPT's that have the email of the current user stored within it.
If I manually type the email address in the constant field eg. joesmith@hotmail.com is works perfectly. But I cant figure out how to create the reference to the current user email.
I've extensively read the filter section in the documentation, but I don't completely understand the shortcode attribute section.
Thanks in advance.

#347545

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

You will need multiple views.

-- Create a "child view" lets say it "B" and add your custom field filter. Select "Shortcode attribute" and add value "user_email" and save your filter.

-- Create a "parent view" lets say it "A" and add child view "B" to it.
For example:

[wpv-view name="your-child-view-name" user_email='[wpv-current-user info="email"]']

Where:
"user_email" is a view's shortcode attribute name you are passing to view "B" from view "A".

More info:
https://toolset.com/documentation/user-guides/using-a-child-view-in-a-taxonomy-view-layout/
https://toolset.com/documentation/user-guides/passing-arguments-to-views/

#347799

Hi Minesh,
Judging by your response, it really sounds like this is simple.... But I cant figure it out 🙁
Can you please baby-step me through this. I've been trying to work it out for hours now and something is just not sinking in.
I've read the More info links also and they just dont seem to provide a specific enough example to follow. Is there any functioning example of filtering using a variable like wpv-current-user info="email"
Jon

#347941

Since Minesh currently has a few days off, I will replace him here in the forum.
I hope this is OK for you.

I hope I didn't misunderstand your query:

1. I plan to show only the CPT's that have the email of the current user stored within it.

- I understand, you have a View, querying a Custom Post Type
- This Custom Post Type has a Custom Field of type "Email", and holds each Custom Post a different (or equal) Email
- this Email is exactly equal to the Emails your WordPress Users have in their Profile
- You want to display a Post in the View only if the Custom Field Email is Equal to the Email of the user that currently is logged in.

2. This should be very simple, no additional View is needed.

- Create a View, query your Post type, no limit, no query filter, nothing.
- In the View Loop, add this:

<wpv-loop>
  [wpv-conditional if="( $(wpcf-email) eq '[wpv-current-user info='email']' )"]Whatever you want to display conditionally[/wpv-conditional]
</wpv-loop>

You can set this up with the Views Conditional Button and then replace your second argument with the proper ShortCode

I used a Custom Field named "Email", you will perhaps need to adjust that.

Please let me know if the above solution works for you, I look forward to your reply!

Thank you for your patience.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.