Home › Toolset Professional Support › [Resolved] Listing site and post relationship with user
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)
Tagged: Toolset Forms, Views plugin
This topic contains 18 replies, has 2 voices.
Last updated by FelipeP5703 5 years, 3 months ago.
Assisted by: Beda.
Tell us what you are trying to do?
I would like to know if it's possible to connect a User with multiple Posts, so when I apply a criteria to the User, then all his posts will be affected.
For example, for the listing site I'm building, I only allow the User to show his website in his Posts if he has X amount of Posts. In this case, let's say 10 Posts. So when he completes his 10th Post, I can go on his profile in the back-end and click allow to show website, now all his posts show his website.
If it's not possible, is there another solution?
I think that you will not even need a manual edit.
For example, you can simply use an HTML Conditional (maybe checking on a custom ShortCode or a Raw View output) - the idea is to check on the amount of post created by the user in the HTML condition.
Simply hide the Website URL Field the user could populate in the Toolset form with that and show it only if 9 posts are created (which means, with this current form he will create his 10th posts, for example)
Does that help to resolve the task?
HTML COnditions are explained here https://toolset.com/documentation/user-guides/conditional-html-output-in-views/, while here you can find a few ShortCodes to count posts by users:
hidden link
Please let me know if you need more help with this.
Beda,
Unfortunately that solution is not feasible for us because we only allow to show the client's website IF all their employees (masseuses) are advertising with us, therefore, one clinic could have 10 masseuses total, another would have 6 total, so it's really individual for us.
What I really wanted to know is this... is advisable to create two Custom Types, one named Client and another named Listing, where on Custom Type Client I can have the criteria that controls the Listing settings? For example, on custom Type Client, I would have allow or not to show the website, and all his Listing would show the website. Or maybe even group all his Listings in View to show below of one of his Listing saying something along the lines of "Here are the other Masseuses from this clinic."
Maybe if I explain my situation, you could tell me a better solution.
We have a site (Listing) that masseuses can advertise. We have individual client, clinics that have multiple masseuses and I have one client that has multiple clinics (6 in total) with different website link, different addresses, but the Listing for one clinic would be identical for all the masseuses in that clinic except for the photos.
So I'm trying to come up with a solution for this dilemma. That's why I thought maybe creating two Custom Types would be it. Also I would like to have reports for all the clients we have, when they came in, when is the due date, etc.
So what do you recommend?
I am not sure I follow the process entirely, also because I don't have the full oversight, but if you want to let's say display a number of posts related to the current post (so in your case, I think the relationship is between masseuse and clinic?), you can do that with Views and you can also do that conditionally, to for example a Custom Field value in the "related" post, yes.
So if we assume a clinic (as a post) has a field that says "can show links". Default unchecked, but when someone checks it, it means the clinic now can show links.
Whatever those links are, you can call this very field (can show links) value in any post that is related to the clinic, or even in views, that query certain content, or even so by directly passing a Post ID when inserting the Field which ultimately allows to call the particular field of a post literally anywhere on your site.
So if you want to (in the front end) display the related masseuses, or clinics (many clinics) only upon conditions of a related post, you'd use the item attribute to "get" the proper field, of the proper related post.
The syntax you should use is explained here, but can also be set when inserting the very field with the Toolset GUI:
https://toolset.com/documentation/user-guides/views-shortcodes/item-attribute/
If you have an existing site with such a setup with related content, I can show you how to display such fields, if you want, please let me know
Maybe this video will explain better - hidden link
Thanks, I'll elaborate below how I'd proceed.
1. I understand you will have paying clients who can list on your websites Clinics. One Paying client may have just one Clinic, or many.
2. Then, the same paying clients, or other paying clients, can be masseuses (in those clinics, or who knows, freelancing).
3. You need a way to A) let the paying client post his clinic/masseuse posts, pay for that, and you need B) a way to control what the single paying client can actually show for his/her posts (Clinics and Masseuses). So maybe one paying client only pays so much or has not enough posts to show a logo, and only once the paying client meets whichever criteria, they shall show a logo. You want to control that on one place, and not on each single post of that client.
I think this pretty much summarizes what you describe in the video.
As first, you need to think about your main "paying client", the real human that will pay for these posts on your site (or if it's free, lets say they will author the posts).
This real person, in WordPress (most natively and by best practice) is a WordPress User. A real User, not post type.
There is only ONE reason to have a Post Type mimicking users, and that is if you want to search thru those users.
But as far I understand, that is not needed on your site.
Hence, you could go with the best practice and als the easiest, just let those paying clients be real WordPress users on your site, by whatever role you give them (Toolset Access is your friend here).
So now you have your user, the paying client.
To this User add User Custom Fields, such as "can publish website" or even, a website input field (URL) to save a global website (for all posts of the user) if that's required. For sure, here you will include your checkbox "can display" for logo, for website, and what you need to control globally for each such user.
You will create Toolset User Forms for you to easily edit those users, and you an even let the clients edit their profile limitedly thru those forms, all controlled by Access, so they do not even need to see the WordPress backend.
After, you need to drive attention to what those Paying Clients (now WordPress Users) do on your site.
They should be able to add Clinics and Masseuses.
If Clinics and Masseuse somehow can relate, then add a Post Relationship between those 2 Post Types.
Then, create Toolset Post forms to add such posts and connect them as required.
The URL fields, can be inserted for each post in a Content Template, for example, and wrapped in HTML Conditionals that check upon the previously set User Fields (and since the author of the post will be that user, you will be able to decide to show or hide a URL/Website, etc)
I can show you this online, if you have some testing site.
It requires a few steps to reach but once you see this in action I Think it will be easy for you to replicate wherever needed.
I've enabled private replies in case you can/want to provide access to a test site so I can show this to you directly, it's easier, than long texts 🙂
All those things (if in the admin area) can already be done with normal WordPress users.
You can query by author in a posts list by simply clicking the author, like so:
hidden link
You can add Custom Fields to users, and those can be filled in (even automatically with some custom code or placeholders) on form submit, so you can store the "join" date easily in a User Custom Date Field.
You can NOT let users expire, so if the expiration mechanism is a requirement, then yes, you need to mimic the user to a post type.
That's another reason, apart of the search, I forgot this.
It does not change a lot, because we can still achieve your goal, even the conditional display of websites depending on the users main post.
I suggest you go ahead and create (if the expiration is required) a Post type that will represent your users (paying clients).
I would name that post type exactly that: "Clients".
Then, follow https://toolset.com/documentation/post-relationships/how-to-create-custom-searches-and-relationships-for-users/ to build the mimicking mechanism of the user to the post type client.
Later we can setup relationship for the client to clinics and masseuse or client to clinics and clinic to masseuse, depending if your clients are BOTH (owner of clinics AND masseuses), or if your clients will be ONLY either of both (clinic owners OR masseuse).
I understand there will be BOTH, so you will need a relationship between the "Client" post type and Clinic post type on one side (a one client to many clinics relationship), and a relationship between "Client" post type and Massesuse post type on the other side (here it will be a one to one relation, because one client cannot be many masseuses at the same time).
You can additionally even add another relation between many masseuses and many clinics, that doesn't matter just yet but can help later if those need to be related.
Once that's done, we can add the fields to the main client post.
According those fields we will display the data on masseuse post and clinic post, or personal "client" post.
Beda,
As I was thinking, there is no need to expire users, only posts. Sorry for the confusion.
But now I have another question. Since we are creating two Post Types, Clinics and Masseuses. Can information of Clinics get passed to Masseuses? For example, phone number, text, location, basically everything except Post title (name of the masseuse) and images. That way, the client does not have to change every single masseuses posts if there is a change in the clinic itself, or when adding a new masseuse, he can just select what clinic she will be in and all the info would be passed. Because there are some instances where one masseuse goes from one clinic to another.
And the other question would be notification of post expiration, since this client pays on the 15th of the month for all of them, is there a way to create a single notification instead of having 30 notifications?
Yes, that is what Post Relationships are for.
You will not "pass" the information from one post to another, instead, you will display or edit that information, on the related posts.
Since you will have a One (Clinic) to Many (Masseuses) relationship probably, you will for example, create a new masseuse and add an existing clinic as "it's parent", or, simply seen as the "clinic this masseuse works in".
Similarly, when adding a Clinic, or editing one, you can add/edit Child Masseuse posts.
So the clinic owner also can update once his clinic, maybe add a new masseuse on the fly, and puff everything will be displayed on the masseuse posts (what he edited in each particular masseuse AND what he edited on the single clinic, since we can display both on a single post)
Notifications cannot be "unified", you will have each notification you set up on the Toolset Form sent for ach event set and each post it affects.
Beda,
Ok, I created the Post Type named Clinicas (Clinic) and added the custom fields, most of them I just used the ones I created for the other Post Type Anuncios (Masseuses).
In the Relationships settings, I created a one to many (one clinic to many masseuses).
When you mentioned:
"Later we can setup relationship for the client to clinics and masseuse or client to clinics and clinic to masseuse, depending if your clients are BOTH (owner of clinics AND masseuses), or if your clients will be ONLY either of both (clinic owners OR masseuse).
I understand there will be BOTH, so you will need a relationship between the "Client" post type and Clinic post type on one side (a one client to many clinics relationship), and a relationship between "Client" post type and Massesuse post type on the other side (here it will be a one to one relation, because one client cannot be many masseuses at the same time)."
I got confused. 🙁
Since we are NOT creating a Post Type to mimic the client (user). What should I do now?
I'm also thinking of the workflow, which could be this:
1) Registration form (user form), there I can ask if they are individuals or clinics. If individuals then it goes to the regular Masseuses form.
2) If chosen clinic then take them to the Clinic Form, where they will fill out Clinic's information.
3) Then they should be taken to another form (Masseuses form 2)?? To upload the images of the masseuses and add her name?
Is that right?
I can't see the related contents on the site you provided me access to.
hidden link
Related to the client post type, that was before you mentioned you do not need expiration:
https://toolset.com/forums/topic/listing-site-and-post-relationship-with-user/#post-1343683
Since you do not need expiration of the "user" or client, there is no direct need for it, that's right
Can you provide me the URL to where you added the content so I can look at how this is outlined now?
OK; I see you have the Post Types Anúncios (Ads, I think), the Clinicas and ... Portfolios
I need to rewind here:
1. You have the clients that are EITHER Clinic owners OR Masseuse OR Both, and Masseuse can work in clinics, one or many.
2. You never mentioned portofolio but I think this is for the clinic or masseuse to add pictures etc? hence probably not part of this task.
Is this correct?
Then we still would need the masseuse post type. I see you use Anuncios, but I think that is not good. You want that post type to be about a masseuse, a person, not about an announcement.
I suggest to reflect that in the very base of the post type name and recreate this, however, it's a detail but it can and will help as you see below (if I would speak about Anuncios instead of masseuse, the whole thing is different).
We need a connection between masseuse and clinic (post relationship between many masseuses and many clinics, or as per your needs).
This can be created here
hidden link
Again I see you have one, but with Anuncios, which I do not suggest.
Then you should add Forms for new clinics, to edit clinics and the same for masseuse. So 4 forms.
Those forms get inserted for clinics the Create Clinic Form in a Page, the Edit Clinic Form to a Content Template, applied to Clinic Post Type.
The same for Masseuse form, the Create new Masseuse form goes to a page, and the edit masseuse to the Content Template applied to the Masseuse form.
This part will cover creating and editing.
Then display is the next step, after you created a few clinics and masseuses.
Ok, so let me clarify a couple of things:
1) The portfolio Post Type was created by the Module Template. I was trying to create a slide for the images of one post type, but I decided not to use it and forgot to delete it. I just deleted it. So forget about that.
2) Anuncios = Masseuses, we use that terminology because in our business there are two types of Masseuses. One is therapeutic and the other is just a person who gives massages. So we thought, instead of having to create two Post Types, one Therapeutic Masseuse and Masseuse, we just decided to call an Ad. The reason being is that we have clients who sometimes switch from one to another and it would probably make it difficult to create such switch. Remember we want to give most of the work to the User, so by having just Anuncios, she/he can just switch from Therapeutic to Masseuses by a dropdown menu in their form.
Other reason is that Masseuses can use a fictitious name (not their real name) and they can hide their faces, while Therapeutic Masseuse have to use their real name and show their faces.
"We need a connection between masseuse and clinic (post relationship between many masseuses and many clinics, or as per your needs)."
I'm trying to understand why do we need a many to many relationship between masseuses and clinics. Is it because it would be easier to switch one masseuse to another clinic?
"Then you should add Forms for new clinics, to edit clinics and the same for masseuse. So 4 forms.
Those forms get inserted for clinics the Create Clinic Form in a Page, the Edit Clinic Form to a Content Template, applied to Clinic Post Type.
The same for Masseuse form, the Create new Masseuse form goes to a page, and the edit masseuse to the Content Template applied to the Masseuse form."
This is getting me confused for the simple fact that a Masseuse might not have a clinic to work with, they might be independent, so asking for clinic information from them might confuse them. Remember, I only have a few clients that work in a clinic. Most of them are independent, thus making me think that having two Post Types might not be needed. Because I can just create a couple of custom fields in the Masseuse Post Type asking if they work in a clinic, if they do, then other options would show for them to fill out.
What do you think?
I see, you have used the Toolset Modules, to kickstart development. Nothing wrong on that, it is just important that we can focus on the related contents only.
I understand also the idea behind Ads now, I would have called that "Masseuse" post type and given it a taxonomy "Type" where you can select the type of it is.
It does not matter, if Ads == Masseuse, I can work with that.
About the relationship, of course now we do not need a relationship between Masseuse as that is simply the Ads post type, which already is in a relation to Clinics:
hidden link
That relationship will allow you to connect as many Ads (Masseuses) you want to one clinic.
This means the Ad (Masseuse) can never work in more than one clinic at the same time.
If this is no issue, then all is good with that relationship.
It allows one clinic to employ many different Ads (Masseuses).
On the Toolset Forms, we will not ask the Ads (Masseuses) to connect to a clinic, if you do not want them to set these connections
That is no issue. The Connection can be established by exactly the users you want (if you only can do that, even this can be controlled).
Who should be able to "connect" an Ad (Masseuses) to a clinic? We will create a way to do that especially for those users.
It is even possible, to let the Ad (Masseuse) decide later during the process if or not a clinic should be connected.
Of course, Ads (Masseuses) would not have to enter data about clinics, that is done by the clinic owners. Correct?
Of course, if the clinic is not important in the structure, asking in a Custom Field if or not the Ad (Masseuse) has/works in a clinic is much simpler than a post relationship.
It depends what you need to do with that clinic.
Does it need to have a single post where you can describe it or contact it? Then better use a Post Type.
If you only need to show Ads (Masseuses) and this is the sole central point you need to describe and have visitors read, then having a simple custom field is enough, that is correct.
Beda,
I'm leaning towards just deleting the Clinic Post Type and in the Masseuses' Form ask if she works in a clinic or not. If yes, then the option to enter the name of the Clinic, the website of the Clinic, and maybe a Logo of the Clinic.
I believe the Clinic owner will be the one having access to site anyways, so I did not want to confuse him/her. Also I would have some settings on the User side of things. For example, on the user field, I would have settings to show or not the website, then all his custom posts should show the site, correct?
How would I set that up?