Skip Navigation

[Resolved] send e-mail to e-mail that is in a parent field

This support ticket is created 6 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 9 replies, has 2 voices.

Last updated by Shane 6 years, 8 months ago.

Assisted by: Shane.

Author
Posts
#553122
toolset.png

I am trying to: Send notification to the parent e-mail field (NOT THE USER FIELD)
Link to my site: private, but if you need please provide a box to share the access
I expected to see: The e-mail sent to the correct e-mail
Instead, I got: The e-mail is sent to my e-mail (USER EMAIL)

I have 1 custom post type: ASSOCIATES
I then created another post type: CONTACTFORM

ASSOCIATES is a parent of CONTACTFORM.

ASSOCIATES has an e-mail field which i want to use to send the contact form notification. This field slug is "e-mail".

After searching and searching the forum for similar problems, i found out that in order to select an option on Cred Form field "Send notification to an email specified in a form field:" i had to declare it as generic_field. So i added this code in the cred form:

[cred_generic_field field='_parent_email' type='email' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist":1,
"default":"[wpv-user field='user_email']"
}
[/cred_generic_field]

I can see the e-mail on the form, and the e-mail is SENT. But the e-mail is wrong and can understand why... it goes for the user_email and not for the email that is on the parent ASSOCIATES email field.

I checked this page to see if this even displays the correct e-mail....
https://toolset.com/documentation/user-guides/displaying-fields-of-parent-pages/
So i replaced:

[wpv-user field='user_email']

with

[types field="e-mail" id="$associados"][/types]

And nothing... no e-mail is displayed on the form and neither beeing sent.

Any help would be apreciated! I want to understand what am i doing wrong.

Thanks!

#553243

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Tiago,

Thank you for contacting our support forum.

It seems that this issue was solved previously by one of our supporters.

Have a look at the link below and link below and let me know if it helps.

https://toolset.com/forums/topic/sending-notification-to-email-address-from-parent-post/

Thanks,
Shane

#553422

Thank you Shane. However, my problem isn't resolved.

I added this code to template functions.php:

add_filter( 'wp_mail', 'my_wp_mail_filter' );
function my_wp_mail_filter( $args ) {
    if(isset($_POST['_cred_cred_prefix_form_id']) && $_POST['_cred_cred_prefix_form_id'] == 861){
        global $post;
        $parent_id = get_post_meta($post->ID, '_wpcf_belongs_associados_id', true);
        $parent_email = get_post_meta($parent_id, 'wpcf-email', true);
        $args['to'] = $parent_email;
    }
    return $args ;
}

CRED FORM id is 861
Parent slug is ASSOCIADOS
Parent email field slug is EMAIL

And still i have no e-mail, dispite that, i get the message "Thank you" with no errors.
I use WP MAIL plugin with SMTP configuration.

However, as i posted above, if i insert:

[cred_generic_field field='_parent_email' type='email' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist":1,
"default":"[wpv-user field='user_email']"
}
[/cred_generic_field]

on the form, and set the notification to be sent to _parent_email, the e-mail is sent but to the user e-mail and not the parent email field.
So my question is...

Isn't there a shortcode to retrieve that field content? So that i can replace

[wpv-user field='user_email']

With the correct shortcode.

Thanks

#553522

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Tiago,

Unfortunately no there isn't a shortcode that can do this.

Since sending an email to the parent is not inherently possible and would need to be done through the use of a hook.

Thanks,
Shane

#553531

Thank you for your time.

Perhaps i'm seeing things not in the best way, but i cannot get more amazed that with Toolset versatility i cannot get a simple contact form that e-mails to an email set on another toolset custom post type to work.

The code posted on the link you provided is from 2015. Shamely i only understand html/css and don't have the hability to figure it out myself.

Is this code updated? Isn't there anyone from Toolset Support that could have a look on it?

Thanks

#553626

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Tiago,

What is the slug of your email field on the parent ?

Thanks,
Shane

#553829
Sem Título23.png
Sem Título.png

Hi!

email slug from parent is "email" as you can see in the screenshot, and that custom type has "contactos para associados" as child.

This is my cred form. It's an autogenerated one.

[credform class='cred-form cred-keep-original']
[cred_generic_field field='_parent_email' type='email' class='' urlparam='']
{
"required":0,
"validate_format":0,
"persist":1,
"default":"[wpv-user field='user_email']"
}
[/cred_generic_field]

	[cred_field field='form_messages' value='']

	<div class="cred-field cred-field-post_title">
		<label class="cred-label">
Contacto para associado Name
</label>
		[cred_field field='post_title' post='contacto-associado' value='' urlparam='']
	</div>

	<div class="cred-group cred-group-parents">
		<div class="cred-field cred-field-_wpcf_belongs_associados_id">
			<label class="cred-label">
		associados Parent
		</label>
			[cred_field field='_wpcf_belongs_associados_id' value='']
		</div>
		
	</div>

	[cred_field field='form_submit' value='Submit' urlparam='']

[/credform]

This code from the cred form shows a dropdown box where i can select a parent, and i see the parent title on the dropdown box option.

<div class="cred-group cred-group-parents">
		<div class="cred-field cred-field-_wpcf_belongs_associados_id">
			<label class="cred-label">
		associados Parent
		</label>
			[cred_field field='_wpcf_belongs_associados_id' value='']
		</div>
		
	</div>
#553937

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Tiago,

Would you mind providing me with admin access tot he website so that i can have a more detailed look at this for you ?

The private fields will be enabled for your next response.

Thanks,
Shane

#553966

Shane,

Don't do anything, the problem is solved, it was dued to my stupidity.
I already receive the e-mail but since i believe i will have another issue i will leave it open and get back to you as soon as possible.

Once again, THANK YOU for your assistance.

Regards,

#554025

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Tiago,

No worries.

Actually we only handle 1 issue per thread. If the new issue is not related to this thread then I would highly encourage that you mark this one as resolved and open a new ticket.

Thanks,
Shane

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.