Dear
Is there an idea when email notification for post relationship will be possible.?
Or is there a step by step guide how we can work around this?
Hello, as of right now unfortunately there is no timeline available for implementing automatic email notifications in Relationship Forms. Step-by-step workaround guides are not available because the solution is custom code specific to the individual notification requirements, but I can provide assistance with any Toolset APIs you might need to trigger something similar programmatically. If you'd like to explore a custom solution and you are comfortable writing some PHP, I can show you how to use our toolset_association_created API to programmatically send a notification email using the native WordPress wp_mail function whenever two posts are connected in a specific post relationship, whether that connection is established using Forms or in wp-admin. I can assist with and explain any Toolset APIs in detail, and I can direct you to documentation for any non-Toolset APIs. If you do not have a working knowledge of PHP, I suggest you consult an independent contractor.
Here is a very basic example based on a post relationship with the slug book-chapter:
// Send an email when two posts are connected in a specific post relationship
// Custom solution in lieu of automatic notifications for Toolset's Post Relationship Forms
// Support reference - see toolset.com/forums/topic/send-an-e-mail-when-a-relationship-form-is-submitted/
add_action( 'toolset_association_created', 'tssupp_rel_send_on_create', 10, 5 );
function tssupp_rel_send_on_create( $association_slug, $parent_id, $child_id, $intermediary_id, $association_id ) {
// only trigger this notification for the 'book-chapter' post relationship slug
if( $association_slug == 'book-chapter' ) {
$to = "recipient@recipient-domain.com";
$subject = "A new post relationship has been established";
$headers = array("Content-Type: text/html; charset=UTF-8");
$parent_title = get_the_title( $parent_id );
$child_title = get_the_title( $child_id );
$body = "The following two posts have been connected in the " . $association_slug . " post relationship: <br />";
$body .= $parent_title . " and " . $child_title;
wp_mail( $to, $subject, $body, $headers );
}
}
Documentation for the APIs involved in this example:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_association_created
https://developer.wordpress.org/reference/functions/get_the_title/
https://developer.wordpress.org/reference/functions/wp_mail/
Let me know if you need additional information about this.