Skip Navigation

[Resolved] Create a email notification by a custom field

This support ticket is created 4 years, 2 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.

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/Karachi (GMT+05:00)

This topic contains 27 replies, has 4 voices.

Last updated by faustoT 4 years, 1 month ago.

Assisted by: Waqar.

Author
Posts
#1834547

thank you very much, now the system works and set the correct expiration date on the registration.
But now I have verified that the email does not start if I set it to leave one day before the date of the event. I created a test event for tomorrow hidden link and entered the email but it did not start, while if imposed as a condition to draft the registration, for example, part immediately.
if you have time to give it a try you can obviously change the time of the test event. Thank you very much for everything you are doing.

#1835151

I think there is a misunderstanding, the Toolset Expiration Post feature is using WP cron job to send the post, it won't be triggered immediately, and it is triggered by WP cron job, you can setup it here:
Dashboard-> Toolset-> Settings-> Forms, in section "Other"-> Post expiration

#1839159
Immagine 2020-11-09 181127.png

Hi, I finally managed to get the mail to work, there were problems with cron jobs. But the email arrives without the fields set by the form. Only text without a reference to the event in question is displayed.
Attached is an image of how the email arrives, without the title, "day-meeting" fields and the link to the event.
Thank you

#1841377

Nigel
Supporter

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

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

Hi there

Luo is on vacation, sorry it has taken a while for someone to reply, we have a couple of unexplained absences which mean we are a bit stretched providing cover.

Just looking at your final reply, if you have used shortcodes in your notification, if the notification is not sent at the time the form is submitted then you need to add the item="%%POST_ID%%" attribute to the shortcodes so that the form notice knows which post to use as the source for the shortcodes.

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

If the problem is something else, please clarify and I'll look into it.

#1841385

Hi Nigel thanks for the reply.
The system should start one day before a post expiration date and send the post parent's data. So we put this in the notification

Good morning,
we remind you that the meeting [wpv-post-title item = "@ appointment-registration.parent"] will be held on the day [types field = 'meeting-day' style = 'text' format = 'j FY' item = '@ appointment-enrollment.parent'] [/ types] .
You can participate from our site by clicking here , or from our channel Youtube or from our page hidden link"> Facebook .

I don't think I could put the other attribute item = "%% POST_ID %%"

#1841739

Hi,

Thanks for sharing the update.

I've checked the form notification in the form "Notifica email" and the item attribute seems to be used correctly.
( i.e. [wpv-post-title item="@appuntamento-iscrizione.parent"] )

During testing with a similar set up on my website, I was able to get the parent post's title successfully in the email notification. This suggests that there is something specific to your website involved.

Can you please share a clone/snapshot of the website, so that we can investigate this on our own server?
( ref: https://toolset.com/faq/provide-supporters-copy-site/ )

Note: I've set your next reply as private.

regards,
Waqar

#1841815

Hi
I'm having trouble creating the file with duplicator, it's too big for my server. Can I avoid selecting something? Or can you generate it yourself with the account I created for you ?.
Thanks!

#1842093

Thanks for the update.

I've managed to create and download a duplicator package from your website.
( I excluded the "uploads" folder to limit the size )

I'm going to perform some tests on this clone and will share my findings as soon as this testing completes.

Thank you for your patience.

#1846965

Thank you for waiting.

During further troubleshooting, I noticed that the value from the item attribute format item="@relationship-slug.role" seems to work if the notification is set to be sent right away, but not if it is scheduled to be linked with the post-expiration.

I'm currently working on a custom code snippet that can be used as a workaround and will share it with you shortly.

#1847633

Thank you for waiting.

I've reported this limitation of using item attribute in post-expiration related notifications to the concerned team.

Meanwhile, a workaround can be to register custom placeholders for getting the parent "appuntamento" post's title and ID in the form notifications:
( ref: https://toolset.com/documentation/programmer-reference/forms/how-to-use-custom-placeholders-in-cred-notifications/ )

For example:


add_filter('cred_subject_notification_codes', 'custom_parent_field_notification', 10, 1);
add_filter('cred_body_notification_codes', 'custom_parent_field_notification', 10, 1);
 
function custom_parent_field_notification( $defaultPlaceHolders ) {

	$current_post_ID = $defaultPlaceHolders['%%POST_ID%%'];

	$parent_post = toolset_get_related_posts($current_post_ID, 'appuntamento-iscrizione', array(
		'query_by_role' => 'child',
		'limit' => 1,
		'return' => 'post_id',
		'role_to_return' => 'parent',
	));

	if($parent_post[0]) {
		$Appuntamento_ID = $parent_post[0];
		$Appuntamento_Title = get_the_title($Appuntamento_ID);

		$newPlaceHolders = array( 
			'%%Appuntamento_ID%%' => $Appuntamento_ID,
			'%%Appuntamento_Title%%' => $Appuntamento_Title
		);

		return array_merge($defaultPlaceHolders, $newPlaceHolders );
	}
	else
	{
		return $defaultPlaceHolders;
	}
}

Note: The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through active theme's "functions.php" file.

After that, you can use these two newly registered placeholders in your email notification body and subject, like this:


Current post ID: %%POST_ID%%<br>
Current post Title: %%POST_TITLE%%<br>
<br>
<br>
Parent Appuntamento ID: %%Appuntamento_ID%%<br>
Parent Appuntamento Title: %%Appuntamento_Title%%<br>
<br>
<br>
Parent Appuntamento URL: [wpv-post-url item="%%Appuntamento_ID%%"]<br>
Parent Appuntamento giorno-incontro: [types field='giorno-incontro' style='text' format='j F Y' item='%%Appuntamento_ID%%'][/types]<br>

#1847851

It works!
Thank you very much you have all been wonderful, it is not the first time you help me and I must say that you are always very helpful and competent.
I wanted to ask if in your opinion the registrations that have reached this moment will arrive or only those from now on will work. I have to figure out whether to send them one by one in the case.
Thanks for everything
Fausto

#1848473

Thanks for the update and glad that it worked.

The content used in the email notification is added to the database pipeline when it is scheduled with the form's submission.

If you'll make any change to the email notification's content, it will only take effect for the notifications which will be scheduled afterward, but not for the ones which are already scheduled.

#1848479

My issue is resolved now. Thank you!