Saltar navegación

[Resuelto] PHP 8 and cred forms

This support ticket is created 3 years, 6 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Zona horaria del colaborador: Asia/Kolkata (GMT+05:30)

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por adamG-6 3 years, 6 months ago.

Asistido por: Minesh.

Autor
Mensajes
#2500655

Sorry to open a new ticket but I have not heard anything regarding https://toolset.com/forums/topic/user-and-post-forms-not-working-after-upgrading-to-php-8-1/. Can someone get back to me please

#2500767

Minesh
Colaborador

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Luo is on vacation and this is Minesh here and I'll take care of this ticket. Hope this is OK.

As Luo shared with his previous reply that there is a critical error once you submit the form:
- https://toolset.com/forums/topic/user-and-post-forms-not-working-after-upgrading-to-php-8-1/#post-2491093

I see the fatal error when there is no input added to your fields assessment criteria 1 to 6.

I'm able to reproduce the same error while I try to submit the form. I see the following code is added to your theme's functions.php file using the save_post hook:

function calculate_fields( $post_ID ) {
     
    if ( get_post_type( $post_ID ) == 'application1' ) {
     
		
            $score1   = get_post_meta($post_ID, 'wpcf-assessment-criteria-score-1',true);
           $score2   = get_post_meta($post_ID, 'wpcf-assessment-criteria-score-2',true);
          $score3   = get_post_meta($post_ID, 'wpcf-assessment-criteria-score-3',true);
          $score4   = get_post_meta($post_ID, 'wpcf-assessment-criteria-score-4',true);
          $score5   = get_post_meta($post_ID, 'wpcf-assessment-criteria-score-5',true);
          $score6   = get_post_meta($post_ID, 'wpcf-assessment-criteria-score-6',true);

       if($score1== '')  $score1 = 0;
      if($score2== '')  $score2 = 0;
     if($score3== '')  $score3 = 0;
    if($score4== '')  $score4 = 0;
    if($score5== '')  $score5 = 0;
    if($score6== '')  $score6 = 0;

        $totalscore = $score1 + $score2 + $score3 + $score4 + $score5 + $score6;
        update_post_meta( $post_ID, 'wpcf-cja-longlist-score', $totalscore );
     
    }
     
}
add_action( 'save_post', 'calculate_fields', 99 );

Can you please try the above code and check if that help you to resolve your issue.

#2500813

My issue is resolved now. Thank you!