Skip Navigation

[Resolved] Automatic email at XX:XX time if not turned off

This support ticket is created 5 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 4 replies, has 2 voices.

Last updated by Waqar 5 years, 2 months ago.

Assisted by: Waqar.

Author
Posts
#1185419

My client has asked me to set up a web site for bushwalkers to send an alert if they do not return by a certain time.

Is it possible with Toolset to have someone
1. register they are due to return at say 2pm Friday
2. When they return they login and tick that they have returned safely
3. If they do not return by 2pm, an email is automatically sent out

thank you!

#1185891

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Janet,

Thank you for contacting us and I'll be happy to assist.

You can use "Automatic post expiration" feature from Toolset Forms plugin to set up a website like this.

We have more details on the topic at the following guide:
https://toolset.com/documentation/user-guides/automatic-post-expiration/

To give you an overview, you'll need two separate forms:

1. The first form will create a post, where a user can set a date and time for the return. You can include a "Date" type custom field for that, which can also include time.

Using the "cred_save_data" hook ( ref: https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data ), you can include a custom function that can update the post expiration date and time to match the value entered by the user through the form:


add_action('cred_save_data', 'set_custom_expiry_from_form',10,2);
function set_custom_expiry_from_form($post_id, $form_data)
{
	// if submitting the specific form
	if ($form_data['id'] == 123)
	{
		// modify the automated expiration date to use custom expiry date
		$post_expiry_date = $_POST['wpcf-return-date-and-time']['timestamp'];
		update_post_meta($post_id, '_cred_post_expiration_time', $post_expiry_date );
	}
}

Note: You'll update the "123" with the actual form ID and "wpcf-return-date-and-time" with the actual slug of your custom field.

In the form's setting, you can set an email notification that should fire, when the post expires (i.e. the user hasn't returned in time).

2. The second form can be an edit form for the user's already created post, and its sole purpose would be setting an empty value for the custom field "_cred_post_expiration_time", so that post expiry date and time is removed and the email notification is not fired. When the user returns safely within the set time, this form can be submitted.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1186210

Wow thank you so much. What a great reply! I'll test it out today.

I do have one other question. The client asked if it was possible to do this as an App - is this possible? If so, where would I start.

thank you!
Jane

#1186577

I've added the hook and created the Submit form.

[credform]
	<div class="form-group">
		<label>Client Name</label>
		[cred_field field="client-name" force_type="field" class="form-control" output="bootstrap"]
	</div>
	<div class="form-group">
		<label>Returning</label>
		[cred_field field="returning" force_type="field" class="form-control" output="bootstrap"]
	</div>
	<div class="form-group">
		<label>Trip Notes</label>
		[cred_field field="trip-notes" force_type="field" class="form-control" output="bootstrap"]
	</div>
	<div class="form-group">
		<label>Notify this address</label>
		[cred_field field="notify-this-address" force_type="field" class="form-control" output="bootstrap"]
	</div>
	[cred_field field="form_submit" output="bootstrap" value="Submit" class="btn btn-primary btn-lg"]
[/credform]

Can you please tell me how to do the second form?

I have created an edit form but I can't work out how to add the custom field "_cred_post_expiration_time" and set it to empty..

Also, would I need to create a user login for this so that they return to the correct form to do the editing?

#1186637

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Janet,

Thanks for writing back and glad my message helped.

> I do have one other question. The client asked if it was
> possible to do this as an App - is this possible? If so,
> where would I start.

- Our Toolset plugins are designed for WordPress websites only, but there are other tools and plugins available which can be used for converting WordPress websites into native Apps.

Following are some useful links:

hidden link
hidden link
hidden link

> Can you please tell me how to do the second form?
> I have created an edit form but I can't work out how
> to add the custom field "_cred_post_expiration_time"
> and set it to empty..

- The function for the second form will become even simpler since it doesn't need to have any field, other the submit button. The user will just need to click the submit button of the form, to let the system know that he/she has returned.


add_action('cred_save_data', 'remove_custom_expiry_from_form',10,2);
function remove_custom_expiry_from_form($post_id, $form_data)
{
	// if submitting the specific form
	if ($form_data['id'] == 123)
	{	
		// remove the expiry date and time value
		update_post_meta($post_id, '_cred_post_expiration_time', '' );
	}
}

Note: You'll replace 123 with the actual form ID of the second form and once submitted, it will remove the post expiration date and time for the post.
( ref: https://toolset.com/documentation/getting-started-with-toolset/publish-content-from-the-front-end/forms-for-editing/ )

> Also, would I need to create a user login for this so that
> they return to the correct form to do the editing?

- Yes, since there will be multiple users involved, you'll need to create a proper membership website, so that each user can access and edit only his own content/forms etc.

By using the Toolset plugins, you can build a strong membership website and the following guides will help in getting started in the right direction:

https://toolset.com/learn/create-membership-site-wordpress-using-toolset-plugins/
https://toolset.com/2018/01/introducing-the-new-membership-reference-site/
https://discover-wp.com/site-types/membership-layouts/
hidden link

For future reference, please note that as per our support policy ( https://toolset.com/toolset-support-policy/ ), only one question or issue can be addressed through a single ticket.

You're welcome to open a new ticket for each new question or concern.

regards,
Waqar

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