Skip Navigation

[Resolved] One-to-many relationship maximum number limit notification

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

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by Luo Yang 2 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#2511213

We have set up a one-to-many relationship between two content types. We have set a limit on the number of child types to 13 per parent.

The question here is to see if there is any way to send a notification to a specific e-mail address when the number of child types reaches that limit? We'd like the site admin to receive an e-mail when the 13th child for each parent is created through a post form.

#2511547

Hello,

There isn't such kind of built-in feature within Toolset Forms plugin, you might consider custom codes, for example:
1) When user submit the post form, you can use filter hook "cred_custom_notification_event_type_condition" to trigger a custom PHP function:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_custom_notification_event_type_condition

2) In this custom PHP function, get the parent post ID by current child post ID:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post
Get all child posts by above parent post ID:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts
If the child posts count value is 13, then return "true" value and send the email notification.

#2511643

That makes sense. We'll have to put this on the Job Board then.

Or how does the post form store the information that lets it know that the numerical limit setting has been reached within that parent and to not allow any more child posts to be created? Would that be easier to query that in some way? Or is that done by the same method you've suggested where it checks for the child posts count value and denies submission of any further child posts after that check has been done?

#2511747

I'm going to go ahead and include the last feature we were hoping to achieve for this Voting system here in this ticket. We do have this on our live Drupal site and are hoping to build the same functionality here.

I know that this is a separate question where you want me to create a new ticket for this. But this is something that I already know is going to require substantial custom code that I wouldn't ask you for help providing it. It does go together though with the issue in this ticket already where we'd like a notification to go to the site admin when all 13 Board Votes are cast for each Freelancer page.

The other functionality we'd like to try to get is a Reminder system that will check if each Board Member has voted on each Freelancer page at 48 hour intervals from the creation of the Freelancer page through the Post Form submission creating it. It will look at each Freelancer page, determine which of the 13 Board Members have voted and which have not. Then it will send a Reminder email to each Board Member user that has not submitted their Board Vote. The Reminder system will continue to send Reminder emails to each Board Member that has not submitted their Board Vote every 48 hours until all 13 votes are in. When all 13 votes are in then this Notification email I've asked about here will be sent to the site admin to let them know voting is done.

I knew the Reminder system would be the most difficult to achieve and would likely require a Job Post on your Toolset Contractors board, so I was waiting for the very end to try to tackle that one. I didn't know if you'd have an easy way to get the site admin notification step done, so I thought I'd ask about that here first to see if we could get that far.

So these do relate to each other and since I'll need to post this on the Job Board, it will be easier to have everything needed together in this ticket. I can then post a link to this ticket to show potential contractors what we are asking for.

Even if we can't get these steps done to further automate this system, we've gotten the rest of the functionality fully done now, which covers everything we *really* needed with it. The requests here are just icing on the cake kind of functionality. This will be FANTASTIC even if we can't get what's in this last ticket done and have the core of what we need already working. Thank you all SO MUCH for all the help getting it this far.

Let me know if you have logic approaches you can provide for the Reminder system like you did for the initial Notification request in this ticket as that would probably be helpful to any potential contractor looking at this. And please keep this ticket open for a bit for us so we can still ask anything that may be needed to achieve this.

New threads created by Luo Yang and linked to this one are listed below:

https://toolset.com/forums/topic/check-if-each-board-member-has-voted-on-each-freelancer-page-at-48-hour/

#2512131

When the limitation is reached, Toolset post form should return an error message and prevent the new post from creating.
What I suggest you above is just for sending the email notification when limitation is reached