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.
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:
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
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.