Skip Navigation

[Resolved] Age calculation and referer doesn't work anymore

This support ticket is created 3 years, 1 month 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)

Author
Posts
#1970555

Hi,
I know, that the following is custom code, but anyway: Since a few weeks without an update, the age calculation in my Toolset form doesn't work anymore and the referer to my form after form submission doesn't work too. I updated the whole Toolset plugins a few minutes ago, but it still doesn't work. I took a look at the code but from my perspective, everything looks good and the log-file doesn't show anything unusual. Regarding the referer problem, here is the (old) thread I had with Nigel:

https://toolset.com/forums/topic/help-using-cred_save_data-hook-option-after-sending-form/#post-1146571

https://toolset.com/forums/topic/help-using-cred_save_data-hook-option-after-sending-form/#post-1146600

You can see an example form for the user here: hidden link

When you enter your birthdate, the following code calculated the age of the person correct in the past, until a few weeks. The calculated age was shown in the confirmation Mail after filling out the form:

<?php

add_action('cred_save_data', 'age_calculation',10,2);
function age_calculation($post_id, $form_data)
{
  if ($form_data['id']==1297)
  {
    $veranstaltungsBeginn = $_POST['wpcf-alter-neu'];
    $veranstaltungsDatum = DateTime::createFromFormat("d.m.Y", $veranstaltungsBeginn);
    $geburtstag = $_POST['wpcf-geburtstag'];
    $geburtsDatum = new DateTime($geburtstag);
    $age = $geburtsDatum->diff($veranstaltungsDatum)->y;
    update_post_meta($post_id,'wpcf-alter-berechnet', $age);
	error_log(print_r("age calculation", true));
	error_log(print_r($post_id, true));
	error_log(print_r($geburtstag, true));
	error_log(print_r($geburtstagNeuUpdate, true));
	error_log(print_r($veranstaltungsDatum, true));
	error_log(print_r($geburtstag, true));
	error_log(print_r($geburtsDatum, true));
	error_log(print_r($age, true));
	
  }
}

Also, if you test the form, you can see after form submission, that the referer link doesn't work anymore. Hope you can help me to fix the problem.
Thanks
Thorsten

#1970821
Farbe_der_Veranstaltung_Error_3_Frontend.jpg
Farbe_der_Veranstaltung_Error_2.jpg
Farbe_der_Veranstaltung_Error.jpg
Ampel_Lichter_Error_3_Frontend.jpg
Ampel_Lichter_Error_2.jpg
Ampel_Lichter_Error.jpg

In addition to my last post, my client and me find some bugs after the update:

- In the backend I have some Custom field for the "Veranstaltungen buchen" CPT. Two of the custom fields don't work anymore after the update of the Toolset plugins:

- For the "Ampel" custom field, I stored the color values in it, but they don't display anymore. I can't save the the styling in it anymore. Before the update, the 3 rady boxes had the following values:
Rot: <span style="height:1.7em;width:1.7em;background-color:red;border-radius:50em;display:inline-block;"></span> #f00
Gelb: <span style="height:1.7em;width:1.7em;background-color:yellow;border-radius:50em;display:inline-block;"></span> #ff0
Grün: <span style="height:1.7em;width:1.7em;background-color:green;border-radius:50em;display:inline-block;"></span> #008000
Please see also attached Screenshots "Ampel_Lichter_Error", "Ampel_Lichter_Error_2" and Ampel_Lichter_Error_3_Frontend

- For the "Farben der Veranstaltung" is is the same problem as for the "Ampel". Before the update the following calues were stored in it, but this doesn't work too anymore:
<span style="height:1.7em;width:1.7em;background-color:#f18b00;display:inline-block;"></span> #f18b00
<span style="height:1.7em;width:1.7em;background-color:#f1b700;display:inline-block;"></span> #f1b700
<span style="height:1.7em;width:1.7em;background-color:#c7c400;display:inline-block;"></span> #c7c400
<span style="height:1.7em;width:1.7em;background-color:#42bae7;display:inline-block;"></span> #42bae7
<span style="height:1.7em;width:1.7em;background-color:#0099ad;display:inline-block;"></span> #0099ad
<span style="height:1.7em;width:1.7em;background-color:#ee8379;display:inline-block;"></span> #ee8379
<span style="height:1.7em;width:1.7em;background-color:#c52133;display:inline-block;"></span> #c52133
<span style="height:1.7em;width:1.7em;background-color:#d8b94c;display:inline-block;"></span> #d8b94c
<span style="height:1.7em;width:1.7em;background-color:#3d7bba;display:inline-block;"></span> #3d7bba
<span style="height:1.7em;width:1.7em;background-color:#80c195;display:inline-block;"></span> #80c195
<span style="height:1.7em;width:1.7em;background-color:#e42c86;display:inline-block;"></span> #e42c86
<span style="height:1.7em;width:1.7em;background-color:#eb7484;display:inline-block;"></span> #eb7484
<span style="height:1.7em;width:1.7em;background-color:#dd7a13;display:inline-block;"></span> #dd7a13
<span style="height:1.7em;width:1.7em;background-color:#81878a;display:inline-block;"></span> #81878a
Please see attached screens "Farbe_der_Veranstaltung_Error", "Farbe_der_Veranstaltung_Error_2" and "Farbe_der_Veranstaltung_Error_3_Frontend".
I had the issue a couple of months ago after a Toolset update and now again, but this time it seems, that I can't fix it.

#1971285
Calculated_Age_Field.jpg

Update to my first post (#1970555) regarding the calculated age. AS far as I can see, he doesn't update the postmeta-table with the 'wpcf-alter-berechnet' field value. It is not in the table as you can see, though I created that field as a custom field.

#1971779

Waqar
Supporter

Languages: English (English )

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

Hi,

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

In order to investigate and reproduce these issues on a test website, I'll need to see how these fields are set up on your website.

Can you please share temporary admin login details, in reply to this message?

Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.

regards,
Waqar

#1974719

Waqar
Supporter

Languages: English (English )

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

Hi Thorsten,

Thank you for sharing these details.

Strangely, the same custom code snippets work on my test website with the form with the same fields, so it seems something specific to your website is involved.

Do I have your permission to download a duplicator package of your website?
( ref: https://toolset.com/faq/provide-supporters-copy-site/ )

This will help in debugging these issues on a test server, without affecting the actual website.

regards,
Waqar

#1974725

Hi Waqar,
That's strange. Sure, you can make a copy with Duplicator. Do you need Duplicator Gold? I have it.
Thanks
Thorsten

#1974727

Hi Waqar,
that's indeed strange. Sure, you can make a copy with Duplicator (I installed the Pro version some time ago).
For some reason I can't see the messages here anymore, neither from you nor from me.
Hope, you will receive my message.
Thanks
Thorsten

#1979307

Waqar
Supporter

Languages: English (English )

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

Thank you for the permission and I've downloaded the duplicator package.

I'm currently performing some tests and will share my findings as soon as this testing completes.

Thank you for your patience.

#1980683

Thanks. I hope you find the problem and a solution.

Thanks
Thorsten

#1980695

Thank you for your update. I hope, you will find the issue and can resolve it.

Thanks

#1983583

Hi Waqar,
do you have any news for me regarding the issues?
Thanks
Thorsten

#1984845

Waqar
Supporter

Languages: English (English )

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

Hi Thorsten,

Thank you for waiting as this investigation took longer than I anticipated.

During troubleshooting, I noticed that the custom code for the age calculation works if:

1. it is placed in the "SeproWeb Child-Theme" theme's "functions.php" file
OR
2. it is kept in the advanced scripts section, but, the AJAX submission option from the form "Anmeldung für Freizeit" is disabled.

This suggests that the way the custom code in the advanced scripts is loaded, it is not executed when the form is submitted through AJAX. For this reason, if you'd prefer the AJAX submission, it would be better to include that custom code through the active theme.

regards,
Waqar

#1985253

Hi Waqar,

thank you very much for solving the first issue with the age calculation. I put the code into the functions.php and deactivated the code in my Advanced Scripts plugin and now this works fine again.

Do you have a solution for the other two problems?

1.) If you test the form, you can see after form submission, that the referer link doesn't work anymore. Hope you can help me to fix the problem.
2.) In the backend I have some Custom field for the "Veranstaltungen buchen" CPT. Two of the custom fields don't work anymore after the update of the Toolset plugins:

- For the "Ampel" custom field, I stored the color values in it, but they don't display anymore. I can't save the the styling in it anymore. Before the update, the 3 rady boxes had the following values:
Rot: <span style="height:1.7em;width:1.7em;background-color:red;border-radius:50em;display:inline-block;"></span> #f00
Gelb: <span style="height:1.7em;width:1.7em;background-color:yellow;border-radius:50em;display:inline-block;"></span> #ff0
Grün: <span style="height:1.7em;width:1.7em;background-color:green;border-radius:50em;display:inline-block;"></span> #008000
Please see also attached Screenshots "Ampel_Lichter_Error", "Ampel_Lichter_Error_2" and Ampel_Lichter_Error_3_Frontend

- For the "Farben der Veranstaltung" is is the same problem as for the "Ampel". Before the update the following calues were stored in it, but this doesn't work too anymore:
<span style="height:1.7em;width:1.7em;background-color:#f18b00;display:inline-block;"></span> #f18b00
<span style="height:1.7em;width:1.7em;background-color:#f1b700;display:inline-block;"></span> #f1b700
<span style="height:1.7em;width:1.7em;background-color:#c7c400;display:inline-block;"></span> #c7c400
<span style="height:1.7em;width:1.7em;background-color:#42bae7;display:inline-block;"></span> #42bae7
<span style="height:1.7em;width:1.7em;background-color:#0099ad;display:inline-block;"></span> #0099ad
<span style="height:1.7em;width:1.7em;background-color:#ee8379;display:inline-block;"></span> #ee8379
<span style="height:1.7em;width:1.7em;background-color:#c52133;display:inline-block;"></span> #c52133
<span style="height:1.7em;width:1.7em;background-color:#d8b94c;display:inline-block;"></span> #d8b94c
<span style="height:1.7em;width:1.7em;background-color:#3d7bba;display:inline-block;"></span> #3d7bba
<span style="height:1.7em;width:1.7em;background-color:#80c195;display:inline-block;"></span> #80c195
<span style="height:1.7em;width:1.7em;background-color:#e42c86;display:inline-block;"></span> #e42c86
<span style="height:1.7em;width:1.7em;background-color:#eb7484;display:inline-block;"></span> #eb7484
<span style="height:1.7em;width:1.7em;background-color:#dd7a13;display:inline-block;"></span> #dd7a13
<span style="height:1.7em;width:1.7em;background-color:#81878a;display:inline-block;"></span> #81878a
Please see attached screens "Farbe_der_Veranstaltung_Error", "Farbe_der_Veranstaltung_Error_2" and "Farbe_der_Veranstaltung_Error_3_Frontend".

Thank you,
Thorsten

#1988701

Waqar
Supporter

Languages: English (English )

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

Thanks for the update and glad that the age calculation is now working.

I've created separate tickets for the other two questions and will reply to them shortly.

You're welcome to mark this ticket as resolved and start a new one, for each new question or concern.

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