Hi Bob,
Ok so i'm checking your response and saw some initial requirements here.
The email address is held in a Member post type, the book is an Item post type. The latter has a Due Date field and a MemberID for the person that borrowed it.
From this I gather that the Member and Item post types are in some form of Post relationship. This would mean you will need to dive into the relationship data in order to get the parent email information.
Take a look at this code below. This is a simple example of how you can get the Parent Post ID and use that to get any field data from the parent post. In this case they were getting the email of the author but you can use it to get the email from a custom field to add it to a notification.
add_filter('cred_notification_recipients', 'video_reply_notification', 10, 4);
function video_reply_notification ($recipients, $notification, $form_id, $post_id){
if (179 == $form_id){
$parent_post_id = toolset_get_related_post( $post_id, 'reply-to-video' ); //Dives into the relationship of the current post type of the form.
$author_id = get_post_field( 'post_author', $parent_post_id );
$post_email = get_the_author_meta( 'user_email', $author_id );
$recipients[] = array(
'to'=>'to',
'address'=>$post_email,
'name'=>'',
'lastname'=>''
);
}
return $recipients;
}
For more detailed explanation on this hook you can see the documentation below.
https://toolset.com/documentation/programmer-reference/cred-api/#cred_notification_recipients
Now for the relationship information you notice they are using the toolset_get_related_post() function to get the parent post ID.
The documentation that correspond to this can be seen below.
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post
The last thing you will need to do is to have some way to trigger the email. There are 2 ways to do this. Our Toolset Form can trigger emails based on Post Expiration.
The expiration date information is stored in a custom field on the post so you will need to manually set this with some custom code.
https://toolset.com/forums/topic/set-the-post-expiration-date-within-a-form/
The thread above has an example of how this is done.
Please let me know if these resources were able to assist you.
Thanks,
Shane