Tagged: ,

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #305271

    Hello! my contact form works perfectly. Thanks!

    I want to process the data instead of sending an e-mail. I know, that I need to change the code here:

    //hook to stop execution here and do something different with the data
    $proceed = apply_filters('avf_form_send', true, $new_post, $this->form_params);			
    if(!$proceed) return true;

    But I am not sure how to get the values and hook my own filter for the processing.

    Best regards.

    #305276

    Hi tludwig!

    You can use the $new_post and $this->form_params variable to process the data. If you don’t want to send a mail and just use the variables with your application make sure that the hooked function returns false like:

    
    	add_filter('avf_form_send', 'avia_process_form_data', 10, 3);
    	function avia_process_form_data($send, $new_post, $form_params)
    	{
    		//your code which processes the  $new_post and $form_params data.
    		return false;
    	}
    

    If you want to send a mail after you processed the data use this code instead:

    
    	add_filter('avf_form_send', 'avia_process_form_data', 10, 3);
    	function avia_process_form_data($send, $new_post, $form_params)
    	{
    		//your code which processes the  $new_post and $form_params data.
    		return true;
    	}
    

    The variable $new_post contains the submitted form data – you can query it like:

    
    	add_filter('avf_form_send', 'avia_process_form_data', 10, 3);
    	function avia_process_form_data($send, $new_post, $form_params)
    	{
    		foreach ($new_post as $current_key => $current_post)
    		{
    			//loop through all contact form fields. $current_key contains the field name, $current_post the corresponding value.
    		}
    		return false;
    	}
    

    You can also combine this filter with other wordpress filters or actions…

    Cheers!
    Peter

    #305293

    Thanks for your quick answer.

    I copied your code, but it does not have an impact on the result:

    			//hook to stop execution here and do something different with the data
    			$message = "TEST";
    			
    			add_filter('avf_form_send', 'avia_process_form_data', 10, 3);
    			function avia_process_form_data($send, $new_post, $form_params)
    			{
    				foreach ($new_post as $current_key => $current_post)
    				{
    					//loop through all contact form fields. $current_key contains the field name, $current_post the corresponding value.
    					$message .= "test";
    				}
    				return true;
    			}
    			
    			$proceed = apply_filters('avf_form_send', true, $new_post, $this->form_params);			
    			if(!$proceed) return true;

    I commented the $message = ""; out below in the code. But the content of my mail is still the same as before.

    • This reply was modified 10 years, 4 months ago by tludwig.
    #305299

    Hi!

    1) You don’t need to modify the contact form code/class – you can add the code I posted above in the child theme functions.php file, enfold/functions.php or you can create a custom plugin.

    2) The question is what you want to do with the form data. If you just want to process it without sending emails please use this code:

    
    	add_filter('avf_form_send', 'avia_process_form_data', 10, 3);
    	function avia_process_form_data($send, $new_post, $form_params)
    	{
    		foreach ($new_post as $current_key => $current_post)
    		{
    			//loop through all contact form fields. $current_key contains the field name, $current_post the corresponding value.
    		}
    		return false;
    	}
    

    Then insert your custom code (which processes the form data) below the php comment line.

    
    //loop through all contact form fields. $current_key contains the field name, $current_post the corresponding value.
    

    You can i.e. store the submitted data into the database, write it to a text file, etc. Note that I can’t provide this code because it depends on your php application and it’s also beyond the scope of our support forum.

    Cheers!
    Peter

    #305332

    Thank you, Peter.
    I will try.

    #305342

    Okay, I got it. Thank you very much.

    But I ran into another problem. With the inserted code the data of ALL forms is now processed. But I need to distinguish between a contact form and my custom form.
    Is there an option in the theme for distinguishing between two forms? I checked both with FireBug and both forms have the following ID:
    avia_generated_form1 1

    #306148

    Hey!

    Refer to this topic:
    https://kriesi.at/support/topic/contact-form-indicator/#post-292303

    Best regards,
    Josue

    #676971

    Hi,

    using avia_process_form_data($send, $new_post, $form_params) works fine for processing custom code.

    Is it possible to modify the $form_params[‘success’] Message after the form was sent?
    I need to show an error message if the custom code processing has failed.

    best regards

    #677381

    Hi,

    Not possible using the avia_process_form_data hook, you’d need to modify the /framework/php/class-form-generator.php file directly (line 253).

    Best regards,
    Josue

    #992553
    This reply has been marked as private.
    #992990

    Hi,

    You need to escape the ” quote like:

    
    $att = "onclick=\"_gaq.push([ '_trackPageview' , 'UA—......\" ";
    

    Reference https://www.virendrachandak.com/techtalk/php-double-quotes-vs-single-quotes/

    Best regards,
    Dude

    #993292

    Thank you Dude, but I’m not a developer, do you mean not using the last double quote or the first double quote onclick?
    Reference https://kriesi.at/documentation/enfold/contact-form/#toggle-id-6

    #993295

    Hi!

    You need to add a \ sign before the two double quotes which follow the onclick=…

    Regards,
    Peter

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.