Accueil › Toolset Professional Support › [Résolu] Template or conditional logic?
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.
Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.
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)
Marqué : Types plugin, Views plugin
Ce sujet contient 8 réponses, a 2 voix.
Dernière mise à jour par Ljuba Il y a 6 années et 2 mois.
Assisté par: Nigel.
>>> Tell us what you are trying to do?
==> Mainly, I have most complicated Content Template for most complicated post type ('Accommodation'). Template is done entirely on Toolset Content Template and Boostrap 4 (View Loops are also modified to fit Bootstrap 4). So, no Layouts or any other Page Builders. Now I should to see how to set different 'levels' of frontend display content depending on (I guess that I can call it as) 'membership level'. So, I will have 3 levels - Free, Basic, Complete (existing content template is for 'Complete'). Main and most important fact is how once upgraded, 'membership' will remain forever (no downgrades).
Probably will be 'normal' if I will start to follow Toolset membership demo site, but I started topic as I think how it could be much more efficient (with significantly less work and queries). Basically, for such kind of scenario is to think not just about website frontend, but also about 'member' Dashboard content (view). In real life, Free content will be collected and published by Editors (website employees) and content is minimal with basic informative facts/elements. Only if 'item' owners (business owners) want to do, they should be able to extend 'exposition' of its own data (features, images,...) on 'Basic' and/or 'Complete' 'level'. It means that in fact, for Free 'level' I don't need Dashboard (frontend) and will not be any 'member' (user, to 'own' 'property'/post).
Also, difference for 'Basic' and/or 'Complete' 'level' will not be in content (maybe part), rather in 'enabled services' (online payments, bookings and 'promotions'). So, 'payments' and 'promotions' are part of the content (content is within separate child posts).
Basically, my idea is to enable full Dashboard content for each /membership level' and to control only visibility of website frontend content. All from admin backend. Simple Admin Dashboard View with the list of the 'members' and checkboxes (select,or whatever) for 'membership level' (some other functionality should be added, like account payment balance, but not the subject of the topic).
QUESTIONS
1) How to set such 'Dashboard view' (some example or explanation)?
2) I guess that I can make on same post Content Template 3 different Bootstrap containers and 'wrap' its visibility conditionally depending on state of the Dashboard checkmark ('Free', 'Basic' and/or 'Complete' 'level'), rather than any other technically possible solution. Is it correct, or there is some 'better' and/or more simple solution?
3) As 'Free' post will already exist, how to connect such post with 'new member' (how to populate member Dashboard content)? Question maybe looks 'stupid', but it is not, as I cannot allow how users itself can select available 'properties' and manage it (in such case everybody can make any kind of 'mess'). I guess that it can be done by initial settings of user for posts, as 'Drafts' and only after first administrator approval to be changed it to 'Publish' (how it can be done?), but should be taken in account how also should be disabled availability of user to 'switch' property (after such approval). I mean, new 'property' will require new 'membership' (as it is new 'business').
Situation is slightly more complicated as in real life, one 'business' can be 'owner' of many 'business' (ie hotel chain, or hotel with restaurant --> is also already two 'businesses',...). Editors will be 'forced' to initially populate/create every ('free') business (property) separately (hotel is one business and restaurant is other). That is also because owner in real life can decide to be 'member' for one business, but to let it 'free' other business. Briefly, by paid new 'membership' owner must be able to 'merge' existing business with new added business, as well.
Les langues: Anglais (English ) Espagnol (Español )
Fuseau horaire: Europe/London (GMT+00:00)
1. This dashboard, it is for the users (owners of the businesses) or for administrators of some kind?
I assumed you were talking about a dashboard for users to be able to see and manage their own content etc., but you talk about checkboxes for specifying the kind of account they have (free, basic, complete), which doesn't sound like something a user should be able to change.
The most obvious—and optimal—way to link users to content is as post author, rather than, for example, using post relationships to connect a profile post to other posts.
Given that you have a lot going on on your site and you will want to minimise unnecessary or complex queries, make the users the authors of their content (post_author is a standard post field and so queries are optimised for this).
Then it should be straightforward to show that user's content in a dashboard (especially if the user is the current user, i.e. the dashboard is for the user themselves, and not for some administrator looking at their profile).
2. Basically, yes. You want to display different output depending on some test (related to their 'membership level'). So you need to show different content per the results of that test.
To avoid this getting too messy I would take a modular approach, and make an unassigned content template for the free version, another for the basic version, and another for the complete version, and then in the 'parent' template include one of these templates conditionally.
3. When a user 'claims' a business you can assign them as post author.
In something like a membership site you would typically use roles to determine capabilities, e.g. your users would have different roles for free, basic, or complete.
That becomes more complex if you want them to be able to claim multiple businesses and have different levels for different businesses, e.g. basic for one and complete for another. I don't have a solution for that. Given that your restaurants, hotels etc. are child posts of a business post, I would have the membership level pertain to the business post, and have any child posts inherit the same.
1A) Dashboard is for administrator and question is for backend ("but you talk about checkboxes for specifying the kind of account they have (free, basic, complete), which doesn't sound like something a user should be able to change." > so, you are right).
1B) So, I thought that by that checkbox admin can switch the content template (see next), from free to paid. In other words, when user pay (one time payment), admin checkbox his account and switch the template to full content display.
That is something what should to be simple (as it is only simple user list with checkboxes, but in WP backend - is it mean sort of new post type?), but how to make it?
2) Nice advice about 'mess' (that I expect - advice). Thanks.
3A) I see. Is it solution to 'force' employees that also on first creation of business, they start from 'Business' (and so on) with the name of owner account creation and that after payment I have basically just enable access to user to that account (how to do this???). So, probably is something trough membership solution.
3B) If above will work, than just should be solved how to handle different level of content view per child posts base (so, hotel, restaurant, ....), if owner want to pay just one business (ie). Any idea here?
Les langues: Anglais (English ) Espagnol (Español )
Fuseau horaire: Europe/London (GMT+00:00)
Hi Ljuba
Toolset doesn't provide any tools for modifying the WordPress admin pages, you have the normal pages available, such as edit pages for posts and pages, and user profile pages where you can update custom user fields.
So if you wanted a checkbox on a user profile to specify the kind of template that would be used for this user's content, you would need to use the normal edit profile page for each user.
If you wanted a "fancier" implementation you might have to craft your own admin page. That's outside the scope of what we can discuss here, but there is a great tutorial on what's required here: https://code.tutsplus.com/tutorials/creating-custom-admin-pages-in-wordpress-1--cms-26829 (You probably wouldn't have sufficient flexibility with one of the many plugins you can use to create custom admin pages, but I wouldn't know for sure without trying.)
But I'm not sure you would need such a checkbox if you applied the same rules for each content type (i.e. members with a certain role had its benefits for each content type, e.g. business and accommodation and restaurant etc.), because you could just check the role of the user that is the author of the content when it came to testing which content template to use.
But that contradicts your last problem, about how to have users pay to own some content but not others. If that is a requirement, well, I'd say that for the free content they cannot 'own' it in the sense of being assigned as post author, which would remain some admin account for the whole site. You might be able to work with a scenario where a user pays and gets control (i.e. is post author) of the business and child alojamiento, but doesn't want to pay for the restaurant, which could still be a child post of the business, but they are not post author of the restaurant, the site admin is. And so they are not allowed to make edits of the restaurant post because they are not author of it (their role lets them edit own posts but not posts of others).
OK. If I understand well, you say that I can do all with Toolset Access, as follow:
1) Initially Editors (employees) enter Negocios (and child posts) as 'editor ownership' (logically should to be done like that). Editor filled maximum available fields (as I don't need to complicate and restrict CRED), but display of content remain on Basic Content Template (as far is editor owner of CPT).
2) By payment, administrator 'reassign' Negocio parent CPT and payed child CPT(s) to the business owner (as Author). Not payed child CPT(s) still belongs to Editors, but by 'visitors navigation's' (frontend view) they point (keep to be linked) to Neogocio parent CPT. Display of the content is switched to the Full Content Template by change of CPT ownership.
Sounds totally fine for my needs. Remain question is:
==> Is it some reference site or documentation:
a) how to make that 'ownership transfers'
b) how to reassign Content Template per membership role/level?
==> As I will have two paid membership levels/roles, can I handle it with Toolset (how? Some docs, reference site?) or it is better to use some additional plugin for it (https://toolset.com/forums/topic/multiple-roles/)? As far as I can see, post should be depreciated (https://toolset.com/learn/create-membership-site-wordpress-using-toolset-plugins/#add-custom-role) and I should to be able to make it all with Access, but ... I must to ask (to not waste the time on experiments).
Les langues: Anglais (English ) Espagnol (Español )
Fuseau horaire: Europe/London (GMT+00:00)
how to make that 'ownership transfers'
Well, you are just changing the post author.
First note that when you register a custom post type at Toolset > Post Types in the "Sections to display..." metabox, you must enable post author to be able to see the UI to change post author when editing posts.
So you have a manual option. Edit the post and change the author.
Now, you may want to do this automatically. Depending on how exactly you have the payment processing set up, you might be able to trigger a code snippet that gets the posts which the user is paying to control, and simply use wp_update_post to change the author to the current user (https://codex.wordpress.org/Function_Reference/wp_update_post).
how to reassign Content Template per membership role/level?
Here you will be using conditional shortcodes along with custom roles from Access.
Remember where I talked about using a parent template and including the required basic or full template based upon conditions?
It seems like you need to allow for 3 roles, the site-editor role, and your user-basic and user-premium (or whatever) roles.
The template to display a post (e.g. a restaurant) would be something along the lines of
is the role of the post author = site-editor? >> use the free template
is the role of the post author = user-basic or user-premium? >> use the full template
There are no Toolset shortcodes to display the role of the post author, but you can see how to register a custom shortcode to do that here: https://toolset.com/forums/topic/conditional-display-based-on-user-role-of-post-author/
(Toolset doesn't support multiple roles per user, but that doesn't stop you managing a system where different users have different roles.)
1) "how to reassign Content Template per membership role/level?"
Thanks, that's exactly what will works for me.
2) "how to make that 'ownership transfers'" ==> "Now, you may want to do this automatically."
You are right, I wasn't precise. Yes, I want it automatically. Most likely, this solution (https://toolset.com/documentation/user-guides/charging-payments-with-cred-to-register-users/) should to works for me also. And you are also right about 3 roles.
So, after (https://toolset.com/documentation/user-guides/charging-payments-with-cred-to-register-users/#marking-the-order-as-complete), is it some Toolset topic with example how to "be able to trigger a code snippet that gets the posts which the user is paying to control, and simply use wp_update_post to change the author to the current user", or I should to figure it out from codex link provided by you above?
Just after reply, I realized that actually I can't see how it can be done automatically as I have here two problematic 'loops' to solve (and second looks impossible to be solved). In real life, there will be two 'problematic' situations:
1) Negocio is not registered (so, no post to 'transfer ownership', rather right for creation of new post). I have (more or less) idea how to solve this situation.
2) Somebody can to claim ownership of the 'third party' (could be more than problematic and/or dangerous). I can't see how that can be solved automatic, what left me just manual 'transfer options' available. Actually, I don't think how either Yelp do it automatically (and they have option to claim existing business).
And there is also third (mixed) situation. Somebody decide to claim 'new business' (if option will be allowed automatically) but in reality that business already exists (so, duplication will make damage to site credibility ==> Booking is faced with that problem - business verification not working in over 50% of cases).
You agree that manually is only option (or you have some idea?)?
My issue is resolved now. Thank you!