I have a custom content type of "Community Pages" which has a custom field of "Community Email". I am adding a Toolset Form to the Community page's template where the form should send its notifications to the custom email field.
I have found multiple topics but no clear answer on how to do this seemingly simply thing.
In the "Send notification to a specific email address" field on the form, I have set this to:
[types field='community-email' output='raw' item='%%POST_ID%%'][/types]
No email is received.
I have also added the same shortcode to the body of the email and when testing to an actual email address and the field is blank upon receipt.
How can I go about sending these form notifications to the correct email address?
Hello. Thank you for contacting the Toolset support.
Can you please share problem URL where I can see the form as well as admin access details.
Once I review your current setup of your form and email notification I will be able to guide you in the right direction.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
Is a relationship required? Will that have to be set on every community page? This will be managed by non-technical individuals and I'm trying to make the setup process for new Communities simple.
I've added a one to many relationship between Community Pages and Community Forms now. I have attempted setting this up both Community Page > Community form, and Community Form > Community Page. But on the Community Page edit screen, neither direction shows available options to connect to. When this is working will every Community have to specify the form?
I also notice an additional email field has been added to the form. What is its purpose?
Is a relationship required? Will that have to be set on every community page? This will be managed by non-technical individuals and I'm trying to make the setup process for new Communities simple.
===>
Relationship is not required but if you want to know what community page have what community form requests made - how do you identify?
Do you want to keep relationship? if yes:
- I see you created Community Forms [0 .. 1] << Community Pages [*], that means community form can have many community pages but isnt it should be community pages (one) can have many community form requests?
I'm still confused as to how this will work? Can you recommend the best method for sending an email to the address pulled from the custom field? This should just be a simple contact form. I don't understand why this is so complex.
ok. Just to confirm - you do not want to track later on from admin section from what "Community Pages" the form is submitted - if that's fine - there is no need of relationship as you do not want to know from what page the form is submitted.
If there will be an extra step to assign the relationship for every community, then I don't think we will want that. We can identify where the form is submitting to through the email address.
- I see you created Community Forms [0 .. 1] << Community Pages [*], that means community form can have many community pages but isnt it should be community pages (one) can have many community form requests?
First of all - I've setup the correct "one-to-many" post relationship that is one "Community Pages" can have many "Community Forms":
=> hidden link
Then with your form I've added the Generic hidden field that will hold the current post ID where the form is displayed - the community page post ID.
=> https://toolset.com/course-lesson/adding-generic-fields-to-forms/
Where:
I've given the hidden field name as "@community-page-community-form.parent" and default value as [wpv-post-id]. As you can see with the following screenshot: hidden link
=> hidden link
Then I've modified the Email notification as given under:
Then I've added the following hook to the "Custom Code" section offered by Toolset.
=> hidden link
add_filter('cred_notification_recipients', 'func_send_email_to_parent_post_custom_field', 10, 4);
function func_send_email_to_parent_post_custom_field($recipients, $notification, $form_id, $post_id) {
if ($form_id==373 and isset($notification['name']) && $notification['name'] == 'Send to Community Email Address') {
$parent_id = $_REQUEST['@community-page-community-form_parent'];
$community_email = get_post_meta($parent_id,'wpcf-community-email',true);
$recipients[] = array(
'to' => 'to',
'address' => $community_email,
'name' => '',
'lastname' => ''
);
}
return $recipients;
}
Above hook will use to get the parent post (community page) email address from the custom field "Email Address" and add the community email address to notification recepients.
Everything seem to make sense and I have now tested on multiple forms, sending to two different "community_email" addresses and no emails are received. I've checked server logs and no emails are being fired at all. I sent a password reset email to myself and those are being received, so the Toolset Form is definitely not sending.
Feel free to change the email on any of the Community Pages to test sending to yourself.
One last question is about the emails name field. Currently the name uses the following shortcode: [types field='form-name' item='%%POST_ID%%'][/types] , but the shortcode does not execute, and when the email is received the unprocessed shortcode is visible as the name of the sender.
With that working, I think all my concerns are addressed.