Hello,
I want to sent an email notification on form submit to a user that has a custom field that has a value similar to a value specified in user form.
---
I have custom post "Ticket" that has a custom field "region" (select field with value A, B, C) [parent]
I have a custom post "Tichet Answer" [child]
I have custom post relationship: "Ticket - TicketAnswer"
I have a form to add custom post "Tichet Answer"
I can display the custom field "region" of custom post "Ticket" in "TicketAnswer" add form - [types field='region' output='raw'][/types]
I have a custom field for USER "zone" (select field with value A, B, C)
I want to sent a notification to USER email that has the user custom field "zone" value set to "C" if the post "Ticket" custom field "region" has set value to "C"
Please help me to set this up - I think that i can take the displayed value of custom field "region" that has set value to "C" and pass to a user shortcode that has custom field "zone" value set to "C" but i don't know hot to set this up.
Thank you!
Hello,
There isn't such kind of built-in feature, it needs custom codes, for example:
1) After user submit the child "TicketAnswer" add form, use filter hook "cred_notification_recipients" to trigger a PHP function:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_notification_recipients
2) In this PHP function:
a) Get the parent "Ticket" post ID:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post
b) And get the parent "Ticket" post field "region" value:
https://developer.wordpress.org/reference/functions/get_post_meta/
c) Use "region" value to get all users by USER "zone" field:
https://developer.wordpress.org/reference/functions/get_users/
d) And get user email addresses:
https://developer.wordpress.org/reference/functions/get_userdata/
e) Then setup the results of filter hook "cred_notification_recipients" with above email addresses.
For your reference.