[Resolved] I need advice on how to setup a user directory
The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 7 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.
I am trying to build a website with user profiles. Kind of like a directory.
I want the visitors to be able to search profiles based on name, city (taxonomy), skills (taxonomy), and rating (not sure how to includes ratings yet).
Now I wonder if I should build a complete new post type for this or use user fields to expand user profiles.
I was thinking that using a new post type for this gives more flexibility, but on the other hand I think that expanding profiles is more logical.
Do any of you know if using user profiles for this limits the possibilities and that is is correct that custom post type is more flexible?
Or am I wrong and should I go with expanding user profiles for this?
You are right that logically you would do this by expanding user profiles, but you are also right that creating a custom post type for users gives you more flexibility.
If I were coding this without Toolset (or only using Types) I would probably go with expanded user profiles.
But, currently, you can only have Views custom searches, for example, for posts, not for users, so you wouldn't be able to display users with filters for any of the user fields.
(And taxonomies work with posts, not users, so I would maybe want to rethink how I would do it without Toolset in any case.)
So, a custom post type is the way to go because user profiles cannot be made searchable (with filters) and they cannot hold taxonomies, right?
So a custom post type is the way to go!?
Do you see any problem using post type with what I want to accomplish?
Is using toolset for my website the right tool??
Now I know that I should not use the users profile, the only disadvantage I see is how to get this custom (profile) type, hooked to a user, and prevent them from making more than one.
The thing is, because they don't feature, for example, searching users, they just use user profiles.
And custom search for users is on our roadmap, I just don't have a timetable for when it is likely to be added.
The only real obstacle to going down the users-as-posts route is during account creation.
You can use a CRED user form for new users to register. Even with users-as-posts your users will still need an account and a user profile.
But when the account is created with the minimum required user fields you will then want to create the corresponding user-posts. You can do it in two steps - a user form to register, and a post form to "complete your profile". Or you could use the CRED API and some custom code so that the user completes their profile on the registration form and behind the scenes when the form is submitted the corresponding user-post with the user as post-author is created with its custom fields populated so that to the user it appears as a single step.
Once you have cleared that hurdle the rest is pretty much plain vanilla.
I would hesitate to say anything is easy because it very much depends on your level of experience and own abilities. Toolset lets you create sites without PHP coding but you still need to grasp the underlying WordPress concepts.
I had understood you to mean you wanted to create a review/ratings system for the users. But if you are talking about using a plugin (I'm not familiar with any) then I can see that this would potentially create issues, because they will be designed to work with user profiles and not with users-as-posts. Without studying how such plugins work I couldn't comment on how easy it would be to bridge that.
Say you were rating my profile (where that was actually a post).
Presumably this would work such that various other users could rate me, and when people viewed my profile they would see the average rating.
There are two ways you might go about that. A more disposable way would be to keep a running average which is stored as a custom field. You would actually need at least two fields. One would have the current average rating, the other would have the number of ratings given. So if my average rating were 3.21 from 37 ratings, then when the next user came along and rated me at 4, the new field values would be updated to 3.23 and 38. You are not going to be able to do something like this without the odd snippet of custom code to do such calculations for you.
The second way would involve you retaining all the ratings the user x gave user y and calculating the average on the fly when required. That may be overkill, but involves the same methodology as you will require for reviews (where you surely will want to record what review was given by user x for user y).
To do that you would make a custom post type for the ratings, and use post relationships to link the review post to the review subject (who the review is about). (The poster of the review would just be the post author of the review.) So you are looking at a parent-child relationship, as described here: https://toolset.com/documentation/user-guides/creating-post-type-relationships/
Note, though, that post relationships will get a major overhaul with the next Types update, due, hopefully, in a matter of weeks, and you would be well advised to work on other parts of your site that don't rely them on the meantime. Although existing sites will be transitioned to work as before, it may be that you think differently about how to set them up in the first place.