• Resolved trenccan

    (@trenccan)


    Hello,

    I have filtered data with the cfdb7_before_save_data filter. Everything works fine but the successfull cf7 message suddenly doesnt show up. What is the problem? Am I removed some data from the $form_data array?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Arshid

    (@arshidkv12)

    Please provide complete customized code.

    Thread Starter trenccan

    (@trenccan)

    add_filter( 'cfdb7_before_save_data', function ( array $form_data ): array {
    
    	$ucastnici = $new_data = array();
    
    	unset($form_data['checkbox-osobne-udaje']);
        unset($form_data['checkbox-spracovanie-udajov']);
        unset($form_data['checkbox-obchodne-podmienky']);
        unset($form_data['checkbox-ucastnik-rovnaky']);
        unset($form_data['checkbox-zdravotnicky-pracovnik']);
     
    	$meno = isset($form_data['meno']) ? $form_data['meno'] : 'N/A';
    	$email = isset($form_data['email']) ? $form_data['email'] : 'N/A';
    	$telefon = isset($form_data['telefon']) ? $form_data['telefon'] : 'N/A';
    	$obchodne_meno = isset($form_data['obchodne-meno']) ? $form_data['obchodne-meno'] : 'N/A';
    	$obchodne_sidlo = isset($form_data['obchodne-sidlo']) ? $form_data['obchodne-sidlo'] : 'N/A';
    	$ico = isset($form_data['ico']) ? $form_data['ico'] : 'N/A';
    	$dic = isset($form_data['dic']) ? $form_data['dic'] : 'N/A';
    	$id_dph = isset($form_data['id-dph']) ? $form_data['id-dph'] : 'N/A';
    	$pocet_registrovanych = isset($form_data['_wpcf7_groups_count']) ? $form_data['_wpcf7_groups_count'] : 'N/A';
    	$konferencia = isset($form_data['konferencia']) ? $form_data['konferencia'] : 'N/A';
       
        foreach ($form_data as $key => $value) {
    
        	for ($i=1; $i < 4 ; $i++) { 
        		$meno_ucastnika 	= "meno-ucastnika__".$i;
        		$email_ucastnika 	= "email-ucastnika__".$i;
        		$meno_komory 		= "meno-komory__".$i;
        		$registracne_cislo 	= "registracne-cislo__".$i;
        		$checkbox = "checkbox-zdravotnicky-pracovnik__".$i;
        		
        		unset($form_data[$checkbox]);
    
        		$ucastnici[$meno_ucastnika] = isset($form_data[$meno_ucastnika]) ? $form_data[$meno_ucastnika] : 'N/A';
        		
        		$ucastnici[$email_ucastnika] = isset($form_data[$email_ucastnika]) ? $form_data[$email_ucastnika] : 'N/A';
        	
        		$ucastnici[$meno_komory] = isset($form_data[$meno_komory]) ? $form_data[$meno_komory] : 'N/A';
        	
        		$ucastnici[$registracne_cislo] = isset($form_data[$registracne_cislo]) ? $form_data[$registracne_cislo] : 'N/A';
        	}
    
        /*remove current fields*/
    	unset($form_data['meno']);
    	unset($form_data['email']);
    	unset($form_data['telefon']);
    	unset($form_data['obchodne-meno']);
    	unset($form_data['obchodne-sidlo']);
    	unset($form_data['ico']);
    	unset($form_data['dic']);
    	unset($form_data['ic-dph']);
    	unset($form_data['_wpcf7_groups_count']);
    
    	/*set new fields*/
    	$new_data['meno'] = $meno;
    	$new_data['email'] = $email;
    	$new_data['telefon'] = $telefon;
    	$new_data['obchodne-meno'] = $obchodne_meno;
    	$new_data['obchodne-sidlo'] = $obchodne_sidlo;
    	$new_data['ico'] = $ico;
    	$new_data['dic'] = $dic;
    	$new_data['ic-dph'] = $ic_dph;
    	$new_data['pocet-registrovanych'] = $pocet_registrovanych;
    	$new_data['konferencia'] = $konferencia;
      
    
        }
     
       
         $form_data = array_merge($new_data, $ucastnici);
        
      
        return $form_data;
    } );
    
    Thread Starter trenccan

    (@trenccan)

    It looks like the problem is causing $new_data array. But I cant find out more because I dont know how to var_dump the data from the original $form_data array. As I said before everything works fine but the successful message disapeared. If I remove the part with $new_data, the successful CF7 message on submit is working again.

    Thank you

    Plugin Author Arshid

    (@arshidkv12)

    I think, unseting undefined offset.

    Add following code in wp-config.php and check log file.

    //Enable WP_DEBUG mode
    define( 'WP_DEBUG', true );
    
    // Enable Debug logging to the /wp-content/debug.log file
    define( 'WP_DEBUG_LOG', true );
    

    Check array merge also.

    • This reply was modified 6 years, 5 months ago by Arshid.
    Thread Starter trenccan

    (@trenccan)

    Thank you. WP_DEBUG_LOG helped me. I was a typo in ic-dph variable so it was undefined.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Success message doesn’t show after filter’ is closed to new replies.