2

I have a site where users can use a SafeCracker form to submit an entry. Once they submit the entry, they are taken to a confirmation page that also includes some code to automatically send out a series of emails.

I'm running into a problem where users bookmark the confirmation page, and then every time they go back to it, the emails are sent again.

Is there a way I can compare the entry date/time of the post with the current time, so for example, the emails will only be sent out within five minutes of the original post?

I know I could do something like:

{if entry_date == current_time}
    email code here
{/if}

but that would only work if the times matched exactly. Is there a way to specify a range of a few minutes?

2

You can try MX Calc

{exp:mx_calc expression="{current_time} - 600 "}
{if entry_date > {calc_result}}
 ....
{/if} 
{/exp:mx_calc} 

but still, this is not good solution because whats happens if user will refresh page many times in accepted timeframe? The perfect solution is made small plugin which will do indication that for current entry message was already sent. You can try do this using Remember Me

{if !{exp:remember_me:get entry_id='{entry_id}'}}
  Send message
{/if}

{exp:remember_me:set entry_id='{entry_id}'}
| improve this answer | |
0

I never used Channel Form aka SafeCracker, but I found something on Member Module that can maybe help you.

{if last_entry_date == entry_date}

Probably you gonna have to use nested module tags or embeds to make this to work.

If this answers helps you, please, edit it with your final code.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.