Skip Navigation

[Resolved] Notification if field of any child post is more than X

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

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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/Karachi (GMT+05:00)

This topic contains 21 replies, has 3 voices.

Last updated by Waqar 2 years, 1 month ago.

Assisted by: Waqar.

Author
Posts
#2470055

The access details worked, thank you.

I'll be studying the setup and will share the next recommendations, accordingly.

Thank you for your patience.

#2470673

Just wanted to let you know that I'm still working on this and will share the findings, as soon as I can.

#2471443

Thank you Waqar. Take your time, I appreciate your help.

#2473323

We had an unusually busy forum queue over the weekend, but, I'll be resuming work on this, today.

#2474059

Thank you for waiting.

After reviewing the requirements and performing some tests on my website, I'll recommend controlling the conditional nature of the form notification, through the "cred_notification_recipients" filter:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_notification_recipients

In summary, you'll

1. Create a form notification for the form "Submit Button Only", as you would create it to be sent without any conditions.

2. Next, through a custom function attached to the "cred_notification_recipients" filter, you'll check whether the final requisition meets the criteria for the notification to be sent or not.

If the criteria are fulfilled, you'll leave the recipients of the form notification as it is, which will mean that it should be sent, as normal.

And if the criteria are not fulfilled, you'll set the "$recipients" array to empty, which will mean that it shouldn't be sent to anyone.

3. Inside the custom function attached to the "cred_notification_recipients" filter, you'll have the ID of the current "Requisition" post. Through this, you'll be able to get the related "Req Items" posts too, using the 'toolset_get_related_posts' function:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts

You'll find a relevant code example of this "recipients" manipulation in this support thread:
https://toolset.com/forums/topic/split-send-a-different-notification-email-after-submitting-based-on-whether-or-not-the-field-is-selected/#post-2129671

I hope this helps and please let me know if you have any follow-up questions.

#2475537

So, if i understand correctly, I need to take my existing code and wrap it in the "cred_notification_recipients" filter, which will give me the ID of the current post to use in pulling the child post fields which I can loop through for the condition on my if statement that will determine whether the notification should be sent or not.

Have I got that right?

#2475981

Yes, your understanding is correct.

You'll not need any code in the main function "do_post_things", for the processing of this email notification. You can keep it only for updating any custom field values, on form submission.

The code for conditional processing of the email notification will need to be added to the function attached to the 'cred_notification_recipients' filter.