Skip Navigation

[Resolved] Show fileds of many one to many relationship with a comom fild to a view

This thread is resolved. Here is a description of the problem and solution.

Problem:

My Customer is my current logged in user. I am auto creating a new wp user each time a new Customer is being saved and the common field of the wp user and and custom post type Customer is the email.

So i want to create a view that says
sow All the Jobs where current loged in user's emai = Customer's cutom post type Usermail field

Solution:

You can try with a nested view, for example:

https://toolset.com/forums/topic/show-fileds-of-many-one-to-many-relationship-with-a-comom-fild-to-a-view/#post-1544187

Relevant Documentation:

https://toolset.com/documentation/user-guides/views/passing-arguments-to-views/

https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items

https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-user

This support ticket is created 4 years, 1 month 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by kostasO 4 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#1543807

Tell us what you are trying to do?
I have three post types:
a) Customer b)job, c) Invoice
I have two three one to many relationship a) Customer-Job(one to many) b) Job-payment (one-many) client-payment(one-many)

i want to create a view (or more that of one if needed) that will have a clients summary report
a) Customer 's Jobs
b) Customer 's payments

my Customer is my current logged in user. I am auto creating a new wp user each time a new Customer is being saved and the common field of the wp user and and custom post type Customer is the email

So i want to create a view that says
sow All the Jobs where current loged in user's emai = Customer's cutom post type Usermail field

but i cannot find a way to do it in views

#1544187

Hello,

I assume we are talking about this case:
Three post types:
- Customer (with a custom email field "my-email")
- job
- Invoice

If it is, you can try with a nested view, for example:
1) parent post view:
- Query Customer posts
- Filter by :
Select items with field:
my-email is a string equal to VIEW_PARAM(myemail)
- In view's loop, display below child post view

2) child post view:
- Query job posts
- Filter by :
the post type relationship between "Customer" and "Job"
- In view's loop, display "Job" post information

3) Create a WordPress page, in the page content, you can get current logged-in user's email with shortcode:
[wpv-user field='user_email']
And pass it to parent post view as shortcode attribute, for example:
[wpv-view name="parent post view" myemail=" [wpv-user field='user_email']"]

More help:
https://toolset.com/documentation/user-guides/views/passing-arguments-to-views/
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items
https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-user

#1544595

It works.
Thank you

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