Skip Navigation

[Resolved] Send a notification email to the email address in an email field

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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 8 replies, has 3 voices.

Last updated by nicolaS-3 1 year, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#2563765

Hi,
I'm trying to send a notification email to the email address in an email field called band-email.
Following Shane's indications here:
https://toolset.com/forums/topic/i-want-to-add-an-email-field-from-a-venue-to-an-event-post-form/
I have added a generic field like this

<div class="hidden">[cred_generic_field field='email-target' type='email' ]
{
"required":1,
"validate_format":0,
"persist":1,
"generic_type":"email"
"value":[types field='band-email' output='raw'][/types]
}
[/cred_generic_field]</div>

and then I have selected the email-target field in the notification option "Send notification to an email specified in an email field included in the form:".
The email is not sent.

Then I read Waquar here :
https://toolset.com/forums/topic/send-cred-form-notification-using-generic-fields/
writing: The option "Send notification to an email specified in an email field included in the form:" doesn't work with the generic fields.". But if this is true why I can select the email-target generic field in the email notification wizard ?

I am lost: is there anything wrong in my code or the email isn't sent for other reasons ?

thanks
Regards
Nicola

#2563789

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Nicola

Ordinarily you cannot choose to send an email notification to an email address that comes from a generic email field in the form, it is not available for selection.

You have been able to do it, though, because you are using the advanced editor and have added "persist":1 to the JSON settings for the field (meaning that the value of the custom field will be saved along with the post submitted by the form).

If it isn't working, isn't sending a notification, I suspect it is because where you are trying to provide a default value coming from a types shortcode, you have not wrapped that in double quotes (just as you would if you hard-coded an email address there).

I suggest you temporarily remove the class="hidden" from the field wrapper so that when submitting the form you can see if the generic email field actually contains a useable email address.

#2563865

Hello Nigel,
you are right, I added the double quotes and made the field visible, what I've found is that the field on the form is empty, there is just a <div></div>, nothing else .... any clue ?
thanks
Regards
Nicola

#2564503

Hello,

Where do you display the post form?
If it is single post, you can use item="current_page" attribute to output current post information, for example:
[types field='band-email' output='raw' item="$current_page"][/types]

More help:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/

#2564571
genericfield.jpg

Hi
I added item="$current_page" but nothing changed. Yes, the form pops up in a Kadence modal on a single post page (band). I have another form in another modal that works perfectly, the only difference is that it sends the notification to the post author instead of an email field.
Here is the code that works (author):

[cred_generic_field type='textfield' field='XUID' type='hidden' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist":1,
"generic_type":"user_id",
"default":"[wpv-post-author format='meta' meta='ID']"
}
[/cred_generic_field]

Here is the latest version of the code that doesn't work (email):

[cred_generic_field field='email-target' type='email' ]
{
"required":1,
"validate_format":0,
"persist":1,
"generic_type":"email"
 "default":"[types field='band-email' output='raw' item="$current_page"][/types]"
}
[/cred_generic_field]</div>

As you can see in the attached picture I also placed

[types field='band-email' output='raw' item="$current_page"][/types]

directly on the form and it shows the correct address, while the same is not passed to the generic field (I added a red border, you can see it's empty)
thanks

#2565067

Please try to modify the generic field shortcode as below and test again:

[cred_generic_field field='email-target' type='email' ]
{
"required":1,
"validate_format":0,
"persist":1,
"generic_type":"email"
 "default":"[types field='band-email' output='raw' item='$current_page'][/types]"
}
[/cred_generic_field]
#2565283

Hi Luo,
I saw the changes, generic field still empty. Same with the form positioned outside the modal.

#2566635

Please try to modify the shortcode as below:

[cred_generic_field type='email' field='email-target']
{
"required":1,
"persist":1,
"default":"[types field='band-email' output='raw' item='$current_page'][/types]"
}
[/cred_generic_field]

I have tried it in a fresh WP installation + the latest version of Toolset plugins, it works fine, see below test site:
Login URL: hidden link

Post form with generic email field:
hidden link

See it in frontend:
hidden link

#2566795

Yes ! now it works both inside or ouside the modal. Thank you very much, great support as usual.
Nicola