Hello I would need to send an email notification one day before the single event to those who request it.
My idea was to use the event date field and create a form with cred that starts one day before the event date.
It would be important that it was integrated into the site because it would take the page fields as the content of the email.
It's possible? Do you have any examples? Or do you know if there are external tools that could help me?
Here is an example of the page
hidden link
Thank you
Hello,
I have checked the URL you mentioned above, but get 404 error.
I assume you are going to send the emails one day before the event date automatically.
If it is, please try the Post Expiration setting of Toolset Forms:
https://toolset.com/course-lesson/setting-up-automatic-post-expiration/
If you don't want to change the "event" post status after event date, you can choose option "Keep original status", see section "Using Automatic Expiration on Toolset forms" of above document:
https://toolset.com/course-lesson/setting-up-automatic-post-expiration/#using-automatic-expiration-on-toolset-forms
Hi, I tried to study the article. I have a couple of problems though:
I tried to create a form in which to enter your email in order to receive the notice the day before the event.
I have a problem on the email form because I did not understand how to make more emails be entered, while now I am editing the same.
The most serious problem is that I would like the notification to start one day before the event: if I set the expiration date from the event, there is no way to tie it to the collected emails, if I set it from the form I change the expiration date of the event when I insert the email. Am I wrong something?
The correct link is falacosagiusta.org/programma-culturale/mente-corpo-spirito-stare-bene-un-passo-dopo-laltro/
In your case, I suggest you try these:
1) Create two post types:
- Event, with a custom date field "event-date"
- Subscription
2) Setup one-to-many relationship between "Event" and "Subscription"
3) Setup a post form for creating child "Subscription" post
- With user's email address field
- With expiration date setting, use action hook cred_save_data to update the post expiration date field "_cred_post_expiration_time" value to the parent "Event" date field value
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
- with email notification settings, see the document I mentioned above:
https://toolset.com/course-lesson/setting-up-automatic-post-expiration/
4) In the single "Event" post, display the child post form:
https://toolset.com/forums/topic/forms-for-creating-and-editing-child-content/
Thanks for the valuable reply. I'm stopped at point 3. I created the form, how can I make sure that the email is linked to the event displayed on this page? Should I give the parameter from the url?
[credform]
<div class="form-group" style="display:none;">
<label>[cred_i18n name='@appuntamento-iscrizione.parent-label']Appuntamenti Iscrizioni[/cred_i18n]</label>
[cred_field field='@appuntamento-iscrizione.parent' class='form-control' output='bootstrap' select_text='--- non impostato ---' required='false']
</div>
<div class="form-group">
<label>[cred_i18n name='email-iscrizioni-label']Email iscrizioni[/cred_i18n]</label>
[cred_field field='email-iscrizioni' force_type='field' class='form-control' output='bootstrap']
</div>
[cred_field field='form_submit' output='bootstrap' value='Invia' class='btn btn-primary btn-lg']
[/credform]
Here is the document for "Selecting Parent Posts when Using Forms to Create Child Items in WordPress"
https://toolset.com/course-lesson/selecting-parent-posts-when-using-forms-to-create-child-items/
Please follow above document to setup the child post form
Hi I did it!
But now I have to save the membership expiration date. I tried to add this hook but it doesn't work
Could you please help me again?
add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==36598)
{
if (isset($_POST['giorno-evento']))
{
// add it to saved post meta
add_post_meta($post_id, '_cred_post_expiration_time', $_POST['giorno-evento'], true);
}
}
}
36598 is id form
giorno-evento is date of event
Please check these:
1) Make sure the $_POST['giorno-evento'] value is a timestamp value
2) Use WP function update_post_meta() instead of add_post_meta()
More help:
https://developer.wordpress.org/reference/functions/update_post_meta/
i tried the code snippet but it still doesn't work.
Should I put it in the form or in the function.php?
I thought it's not working because it doesn't fetch the parent post
Since it is a custom PHP codes problem, please provide a test site with the same problem:
1) Fill below private message box with your test site credentials + FTP access
2) Also point out:
- The problem page URL and form URL
- Where I can edit your custom PHP codes, I need to test it in a live website, thanks
Thanks for the details, I can login your website, please provide below details:
Also point out:
- The problem page URL and form URL,
- Where I can edit your custom PHP codes,
thanks
Sure, you can find the form by clicking on "ricevi un promemoria" in the page like this hidden link.
Then access the page of the form where you enter the email.
You can change the php from the toolset settings, custom code and then "expiration date".
For everything let me know.
Thanks!
I assume we are talking about the custom date field "Giorno incontro", I have modified your custom PHP codes as below:
// Put the code of your snippet below this comment.
add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==36598)
{
if (isset($_POST['@appuntamento-iscrizione_parent'];))
{
$appuntamento_id = $_POST['@appuntamento-iscrizione_parent'];
$giorno_incontro = get_post_field($appuntamento_id, 'wpcf-giorno-incontro', true);
// add it to saved post meta
update_post_meta($post_id, '_cred_post_expiration_time', $giorno_incontro, true);
}
}
}
Please test it again, check if it is fixed, thanks
I tried to test and then if I go to see the registration I see that the expiration date is not yet set correctly.
For example here hidden link
Should I remove the expiration date selection from the form? But in that case how do I enter the condition for the notification in the form?
You don't need to change the form setting, I have modified the PHP codes to below:
add_action('cred_save_data', 'my_save_data_action',999,2);
function my_save_data_action($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==36598)
{
if (isset($_POST['@appuntamento-iscrizione_parent']))
{
$appuntamento_id = $_POST['@appuntamento-iscrizione_parent'];
$giorno_incontro = get_post_meta($appuntamento_id, 'wpcf-giorno-incontro', true);
// add it to saved post meta
update_post_meta($post_id, '_cred_post_expiration_time', $giorno_incontro);
}
}
}
Please test again, check if it is fixed, thanks
More help:
https://developer.wordpress.org/reference/functions/get_post_meta/