Home › Toolset Professional Support › [Resolved] Filter View by a related field from great grandparent post
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)
Related documentation:
This topic contains 18 replies, has 3 voices.
Last updated by Shane 5 years, 10 months ago.
Assisted by: Shane.
I am trying to create a View to display a feed of only the Posts which were authored by Members who live in the same Apartment Building as current User.
I have created the following Custom Post Types: Neighborhoods, Apartment Buildings, Apartments, Members.
I have created the following relationships:
between Neighborhood and Apartment Building,
between Apartment Building and Apartment,
between Apartment and Member,
and between Member and WP User Account.
I need to create several conditional Views, but if you can help me understand how to create the first one I can figure out how to build the rest of them.
View 1: A feed of all Posts authored by Members who live in the same Neighborhood as current User.
View 2: A feed of all Posts authored by Members who live in the same Apartment Building as current User.
View 3: A list of all Members who live in an Apartment in the same Apartment Building as current User.
View 4: A list of all Members who live in an Apartment in an Apartment Building in the same Neighborhood as current User.
Hello. Thank you for contacting the Toolset support.
Well - I need more information about the relationship you created. What relationship did you create between all your post types? Is it one to one OR one to many?
View 1: A feed of all Posts authored by Members who live in the same Neighborhood as current User.
=> Where I will find the Neighborhood information of current user? and what posts you want to display here? Do you want to display apartments?
What type of relationships are they?
Sorry for not specifying the relationship types:
between Neighborhood and Apartment Building (one Neighborhood can have many Apartment Buildings),
between Apartment Building and Apartment (one Apartment Building can have many Apartments),
between Apartment and Member (one Apartment can have to many Members),
between Member and WP User Account (the Member CPT has a Post Reference Field called 'Author" which holds the User's email address and connects the WP User Account to the Member post. This connection is created automatically when a during new user account creation process)
Where will I find the Neighborhood information of current user?
Current User inherits all data from its one to one Member post. To determine the Member's neighborhood you have to walk through the hierarchy to determine which Neighborhood their Apartment Building is in. (Member>>Apartment>>Apartment Building>> Neighborhood)
In plain English: Members live in Apartments, Apartments are in Apartment Buildings, and Apartment Building
View 1: A feed of all Posts authored by Members who live in the same Neighborhood as current User
...and what posts you want to display here? Do you want to display apartments?
No, I don't want to display a list of Apartments. I would want to display a feed of all the Posts authored by Members who live in the same Neighborhood as the current user. These would be standard WP posts that a human might write to tell their neighbors about what is going on in their neighborhood.
As I understand - you want to display all the posts from the default post type "post"
- whose Member post author is current logged in user and Neighborhood is the same as the member post's neighborhood.
Can you setup a test example with few posts with the author as well as neighborhood and share the access details that will help me to understand your structure. Please setup the content for the logged in user should share with me with the next reply which I set as private.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
Well - the wp-admin access details you shared with me is not enough. I can only see the profile page when I loggedin.
I've few additional questions that will help me to understand the structure and to know where exactly the information is stored.
Can you please share full rights to the wp-admin user you created so I can check the test content you set up.
Again, Can you please tell me with an example where exactly the neighborhood information is stored for currently logged in user?
Maybe its better if you can share a couple of additional user access details and please share the page/post where exactly you want to display this filtered information with your expected results for those users.
I have set the next reply to private which means only you and I have access to it.
ok, you should have Admin rights now. Sorry, I thought I had done that originally.
you can login to the site as any of these test users with this password:
buildingA.unit1.user@saladatos.com
buildingA.unit2.user@saladatos.com
buildingB.unit1.user@saladatos.com
buildingB.unit2.user@saladatos.com
buildingC.unit1.user@saladatos.com
buildingC.unit2.user@saladatos.com
buildingD.unit1.user@saladatos.com
buildingD.unit2.user@saladatos.com
"Again, Can you please tell me with an example where exactly the neighborhood information is stored for currently logged in user?"
Neighborhood information is stored in the Neighborhood CPT.
To determine which Neighborhood a Member lives in, you look to what Neighborhood their Unit and Building are connected to.
There shouldn’t be a direct relationship between Neighborhood and Member. Instead, a Member’s Neighborhood should be inherited from the Unit they live in. Among other things, this will prevent a Member from being associated with the wrong neighborhood if/when they move from a building in one neighborhood, to a building in a different neighborhood.
Ok - great. Thank you for sharing all the required information.
I checked following is the chain to reach the member post :
Neighborhoods => Neighborhoods Have Buildings => Building have Units => Member has Unit
Now, I would like to know where exactly you want to display the data/content - on which page? member single page? or neighbourhood single page?
Three examples:
hidden link would show all posts by Members who live in the same Neighborhood as the current user.
hidden link would show all posts by Members who live in the same Building as the current user.
hidden link would show all posts by Members who live in EITHER the same Neighborhood OR the same Building as the current user.
Thanks so much for your help on this!
Ok great - thanks for all required information again.
Now, one more question, I'm checking the following post:
hidden link
How can we identify that the above post is linked to what member or neighborhood or unit? is there any connection?
Yes! The connections already exist. The Member living in Apt A is connected to Neighborhood A because Building A is in Neighborhood A.
Member>Unit>Building>Neighborhood
I feel like I have answered the same question 3 different ways and I have provided clear examples but you still don’t understand.
Can you transfer this support ticket to someone else?
ok - sure. I will assign this ticket to another supporter as per your request but there is one connection is missing as far as I can see.
Hi Charlie,
Minesh asked me to take a look at this for you, however i'm not seeing a way how these items are linked to get the correct results.
Take a look one of the questions you asked.
"View 1: A feed of all Posts authored by Members who live in the same Neighborhood as current User."
I checked on your post and found that I'm not able to see a link between Neighborhood and the current user. Unless there is a link between Current User -> Neighborhood -> Members -> Posts then we are not able to list out what you want it to list, because we will be filtering through the relationships to get the final results.
Essentially like this
Current User
- Belongs to Neighborhood A
- -Neighborhood A has Members B, C, D, E
--- Members B,C,D,E has posts A, B, C, D, E , F
----View list post A, B, C,D, E, F
I believe this is what you want but i'm not seeing the linking. I see in your post relationships where there is some linking in relationships but not seeing where these are linked exactly.
This is where we are having the issue.
Thanks,
Shane
The current wp user is automatically linked to a Member CPT during account creation via the 'author' field.
After that, here are the exact names of the Post Relationships which have been built.
Members Posts
Members have Units
Buildings have Units
Neighborhoods have Buildings
What relationship is "missing"?
Using your template from above:
-User has/is MemberA
--MemberA has Unit1
---BuildingA has Unit1
----NeighborhoodAB has BuildingA
-----NeighborhoodA has Members A,B, C, D, E
------Members B,C,D,E has posts A, B, C, D, E , F
-------View list post A, B, C,D, E, F
Hi Charlie,
The relationship that is missing is Neighborhood is not related to anything Except Events, Buildings and Organization.
So you want to list out the Posts but the relationship does not continue down to the Post.
To fix this all you need to do is create a relationship between neighborhood and posts. This way we can nagivate down through the relationship tree to get the correct information.
This is going to take at least 5 different views.
Thanks,
Shane
Yes, it would be simple to add a direct Neighborhood-has-Posts relationship but I don't want the User/Member to have to manually create that connection via a Relationship Form every time they write a new post. I was hoping the Neighborhood to Post relationship could be created through the joins outlined above.
If that is not possible I can create the new Neighborhood-has-post relationship but then I will need to figure out how to trigger a webhook to automatically create that relationship connection so the User doesnt have to.
Are you available to have a live chat?