Skip Navigation

[Resolved] Nested Conditional

This support ticket is created 6 years, 8 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 2 replies, has 2 voices.

Last updated by Adrian 6 years, 8 months ago.

Assisted by: Nigel.

Author
Posts
#619585

I have a bit of a weird user scenario.
I have seen a lot of favourites implementations which are cool.

But what I am trying to do is the following:

I have users with the numeric field company_id -> points to the ID of a custom post type company
A company has a repeating numeric field called "articles".

Basically this means that a user belongs to a company. A company can have multiple favourited articles.

For each favourited article, I want to show on the article wether or not it is in the user company's favourites.

Why? because multiple users can belong to the same company. Each user can add to the company favourites, and all the other users can view those favourites.

How could I implement this?

I kind of understand how to print the company's favourites in a view and how to filter that (hopefully). This question pertains on how to show on an item within the view for the article, that it is already in the company's favourites.

Thank you

#619668

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Adrian

I sort of understand, but I don't follow where you are displaying what.

Am we talking about viewing an article post (a single post, or listed in a View) and the user who is looking at the post belongs to a company (and only one company) and if that company has already favourited the article to mark the article as a favourite?

Or we are on a company page which has a View to list all articles and those which have been favourited should be marked as such?

Or something else?

#619846

I was able to figure it out.

I added a "Favourited Resumes" repeating numeric field to the Company.
I added a company ID field to the user meta

The user meta will contain a company ID.
I wrote a shortcode function that takes the current user's company by ID and compares on each post via a shortcode that displays either true or false if the post is part of that array which is the repeating "Favourited Resumes" field.

Now I just have to figure out how to add them there...