Skip Navigation

[Closed] Toolset Forms email notification to address in Custom Field on current page

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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 0 reply, has 1 voice.

Last updated by Minesh 4 months, 3 weeks ago.

Assisted by: Minesh.

Author
Posts
#2798531

Tell us what you are trying to do?

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?

#2798600

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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.

#2798702

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I do not see any post relationship between "community" post type and "Community Forms" post type.

Do you want to establish one to many post relationship beween "community" post type and "Community Forms"?

#2799100

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?

Thank you for the help!

#2799105

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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've removed the extra field you see on the form.

#2799511

Hi Minesh,

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.

Thank you

#2799513

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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.

#2799519

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.

Thanks!

#2799521

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

We can adjust the relationship while submit the form but then as I shared you created wrong relationship:
=> https://toolset.com/forums/topic/toolset-forms-email-notification-to-address-in-custom-field-on-current-page/#post-2799105

- 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?

#2799535

"community pages (one) can have many community form requests?" Yes this sounds correct. I wasn't sure how to setup the relationships.

#2799661

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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:

Post ID:  [types field='community-email' output='raw' item='%%POST_ID%%'][/types]

Name: [types field='form-name' item='%%POST_ID%%'][/types]
Email: [types field='form-email' item='%%POST_ID%%'][/types]

Subject:
%%POST_TITLE%%

Message:
[types field='form-message' item='%%POST_ID%%'][/types]

More info:
- https://toolset.com/course-lesson/send-notifications-when-someone-submits-the-form/#displaying-post-information-in-notifications
-

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.

More info:
- https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/
- https://toolset.com/documentation/programmer-reference/cred-api/#cred_notification_recipients

Can you please confirm it's working as expected now.

#2799709

Hi Minesh,

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.

Thanks again for your help, I appreciate it!

#2799806

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check now.

I found that you set the email notification to trigger on "When submitting the form" and I can see now emails are send.

#2799874

Thanks Minesh, emails are now being received!

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.

Thanks again for the help!

#2800093

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

What you want with "From" name?

Do you mean instead of site name you want to use the custom field "form-name" and email?

The topic ‘[Closed] Toolset Forms email notification to address in Custom Field on current page’ is closed to new replies.