Skip Navigation

[Resolved] Taxonomy and 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.

Author
Posts
#921802

Nigel
Supporter

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

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

You can use Access shortcodes to control within a template what gets shown to different user roles: https://toolset.com/documentation/user-guides/access-control-texts-inside-page-content/

So within the same template you can show something to premium users and something else to basic users and something else to free users, etc. (assuming you are basing the plans on different roles).

Now your templates could start to look pretty messy with all of these toolset access shortcode conditions.

But you can nest content templates.

So you could create a master template assigned to negocios, for example, and then create a series of "child" templates for negocios, one for premium users, one for basic, one for free (none of which are assigned templates), and then you insert these "child" templates into the master template and wrap each shortcode that pulls in the child template inside access shortcodes.

This will work with Views Content Templates. If you are not using them (because you are assigning an Elementor template to negocios, for example) then nesting templates won't work, but you should still be able to use access shortcodes inside Elementor text/html modules.

The Views templates version is a neater solution because then you will have "this is the template for negocios for basic users", "this is the template for negocios for premium users" etc.

#921815

Thanks for reply. I will not close the ticket as I will start (hopefully finish) full Content Template for Negocios and than try to see did I get how to do your solution. In fact, I will be faced with lot of the challenges as Elementor not control best the templates (via his template functionality and directly) and there are also lot of the incompatibilities with the Views (we found it before with Minesh). It will be adventure how to puzzle it, but...

So, we will see when you will be back from holidays. I will update the ticket when I do ti.

Nice vacations.

#922553

I'll mark this ticket as pending an update from you, and Nigel will pick it up when he returns from vacations.

#948945

I'm answering because of Toolset robot. When Nigel will be back, I will update the state.

#949287

If I'm not wrong, Nigel is back. So, you can see new site data at https://toolset.com/forums/topic/taxonomy-view-with-a-taxonomy-view/#post-923634

Please keep working on old, as on new will be very easy - mess (Beda, you and me).

However, on new site, you can see in demo post of Negocio, how it generally should to look. you will notice that after Beda remarks (and I also prefer it), all is done trough Elementor (Elementor also control the single.php), but via Views. It also looks that Views nicely controls Elementors Templates shortcode (as custom added shortcode) including conditional logic.

TOPIC

Remaining issue is - how to control and display situation that Negocio can have more than one businesses (type and/or locations combinations)?

1) First problem is - fact is that most businesses will get only one single business type/location, what leaded me to the 'trap' to mix fact how to structure registration of the business/users (Types and CRED topic) with issue how to display content (Views and now Elementor instead of Layouts topic). Actually, I want to say that I did wrong in Beda topic site, as there is displayed Negocio, but I should in fact to display Business Activity (type and/or location), what mean Accommodation, Gastronomy, Service or Shopping, as nobody will search and nobody want to display business, they looking for 'service'. In other words, I have now displayed Business Activity as child, inside of Business (as parent) and should be the opposite - I should to display parent data within the Child Post. Or as Breadcrumbs, it should not to be Home > Negocios > My Company - it should to be Home > Negocios > Alojamientos > My Hotel. Negocios single.php in fact should to display child archived Views or extended page of "headquarter" (Sede) with extended 'Sobre nosotros', if client need such single.php page.

If that is right, I think that I get it covered (I know how to do it).

2) Basically, main problem is that I don't know how to control number of allowed business types/locations - child posts. That is the same issue also with number of Rooms (child post), number of displayed products (Shopping child post), .....

So - How to do it (specifically - how to create different levels/plans with different numbers of allowed child posts)?

P.S. Once if member set (ie) 4 business types, he never again will go 'lower' (downgrade status), he can just go 'up' (to upgrade status with more ). In other words, I will be satisfied with sort of Dashboard (backend) manual control of 'user membership level'.

#950407

Nigel
Supporter

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

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

I looked at the new sample site and I think I understand how you have it set up, where you have a sample negocio (Hotel Bumba) which is really only an alojamiento business and has an alojamiento child post (also "Hotel Bumba").

If I view the Hotel Bumba *negocio* post on the front end, it is displayed using an Elementor template, and includes a View to insert the Elementor template to display the alojamiento.

I was wondering why the alojamiento template isn't inserted directly into the negocio template, but that is presumably because the negocio can have multiple alojamientos and they each need listing. So far so good, that makes sense.

Assuming you have a search page where users search for alojamiento, then you want that to return alojamiento posts, not the parent negocio posts. That's not a problem because you can output fields from the parent post when displaying the child post. With Views Content Templates you can add an id attribute which sets the context for all of the fields used in the template, rather than having to add the id attribute to each individual field, I'm not sure if you can do the same with elementor templates.

Your second question looks like a question about the implementation of the form submission process, not the display process.

A basic requirement is that you create different roles for the different user levels (standard, premium etc.), and then you will need custom validation with the submission form (which could mean one form with complex validation, or different forms displayed to different user roles, each with simpler validation).

It rather depends on what route you go down for the forms, so I can't really say without knowing more.

If that is the case then I'll split off the form issues into a separate thread.

#950471

1) First, welcome back and to say how according Beda, this week update will integrate Elementor, what will make all easier. Also, even for now, when I add to Toolset custom shortcode support for elementor-template, it looks to works all fine.

2) I was wondering why the alojamiento template isn't inserted directly into the negocio template, but that is presumably because the negocio can have multiple alojamientos and they each need listing. So far so good, that makes sense.

EXACTLY

3) <Your second question looks like a question about the implementation of the form submission process, not the display process.

Yes and no. At this point, I'm interested for Types structure. If existing concept of the Types structure (posts and field groups) with Elementor/Views implementation will be capable to do with success such limitation of the posts number within CRED, we can close the ticket.

For CRED, if I will need help, I will open other ticket.

#951387

Nigel
Supporter

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

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

You will no doubt have seen that when you set up relationships you can set limits, so for a one-2-many relationship you can specify that there is a limit of 5 child posts, for example.

But these are global limits, you can't differentiate according to user role, for example, so that basic users can create 2 children and premium users 5.

Also, this will work in the backend using Types to add the child posts, I haven't tested it to see what happens if you try to add too many child posts with CRED forms on the front-end. It should be tied into CRED validation, but I'm not sure if it is without setting up a test site.

So you will, I think, need to put the logic for this into a custom validation function that compares the number of existing child posts with how many are allowed given the role of the user. That could be CRED, or it could be another forms solution.

You may also want to include conditional shortcodes to only display links to add child posts if the current user is allowed to add more (rather than have them complete and submit a form and receive an error), but such logic would belong in a custom function that did pretty much the same as the custom validation.

#951425

1) Yes, global limits is not a solution (except if I will not create 100% same child posts with different names (slugs) and post limits and assigned them to the plan - what not sounds like rational solution).

2) Yes, it is about front-end control (CRED), but backend structure.

3) Actually, here is about the dilemma (allegedly Types 3.03 solved the BUGS) - 'Child Post Types' (CPT) or 'Repeater Field Groups' (RFG). I could be wrong, but if I'm not, I think that RFG now support conditional logic in CRED, as well in Views and sounds better option than CPT. Problem is that I sincerely don't have any clue how to control CPT numbers and I'm surprised that it looks how Toolset also don't have some experience with the issue, as for me sounds logical problem for any project. Nobody want to allow that users/members can 'produce' unlimited number of posts (or I'm wrong???).

Here is dilemma as you wrote (in this topic) how CRED don't have yet developed mechanism for RFG. But here I found similar (oposite) example - https://toolset.com/forums/topic/custom-validation-on-cred-form-with-repeating-field-groups/#post-632144.

So, what is the real situation (and solution)?

#951433

Actually, can this be done with CRED and child CPT?

hidden link

#951436

Probably more appropriate as user or user role could be similar.

hidden link

#952364

Nigel
Supporter

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

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

"Nobody want to allow that users/members can 'produce' unlimited number of posts"

Right, and the solution has always been to add custom validation to the forms to reject adding further posts when some limit has been reached.

With forms that add repeating field groups (which are a custom post type) you can add similar custom validation that rejects a submission, or you could only display the link to the form if the limit had not yet been reached (which would require some custom code for the condition to count the number of existing rfg posts).

We don't have equivalent hooks to those of formidable forms.

You would need to use wpv-conditional with a custom function to determine whether the form displays or not in the first place, and the cred_form_validate hook for server side validation.

#952427

Thanks for help (and patient).