WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
Can't make hooks work (5 posts)

  1. brack
    Member
    Posted 1 year ago #

    The task is to make a simple form for donation, which has two fields: department to donate to, and amount. This form suppose to open paypal window with preinserted values taken from form. Apparently on_sent_ok doesnt pick values, so I decided to use hooks. I tried action hooks wpcf7_mail_sent and wpcf7_before_send_mail the first one sents mail to me but doesnt do anything else, the second one doesnt do anything at all but they are definitely picked by form because if I use those hooks form simply hangs in the end, circle arrows on the side of submit button are spinning continuously and I never see success message. Also i tried filter wpcf7_form_action_url and I can see that action in form is changed correctly but I only see endless spinning arrows and no action. What do I do wrong? I suspect that form tries to work with paypal url via ajax but it cannot. How to work around this issue? I really dont want to change the code in any plugin's file, want to use genuine features.

    http://wordpress.org/extend/plugins/contact-form-7/

  2. brack
    Member
    Posted 1 year ago #

    Anyone? I'm still struggling. Here is one of the hooks I tried, the form just hangs, doing nothing, no confirmation messages after submission, but I receive email with the form data:

    add_action( 'wpcf7_mail_sent', 'my_wpcf7_function' );
    
    function my_wpcf7_function( $contact_form ) {
    	$title = $contact_form->title;
    	$posted_data = $contact_form->posted_data;
    
    	if ( 'Contact Form' != $title ) {
    
    	   $redirect='http://paypal.com'; //just an example, but URL bust be dynamic
    	   header("Location:$redirect");
    
    	}
    }
  3. HarrisITServices
    Member
    Posted 1 year ago #

    I am having the same issue and cannot figure it out. I have tried the following two snippets of code in functions.php and the email sends but the page never redirects. It just stays with the little spinning circle next to the submit button. If anyone has figured this out please let me know as this is driving me nuts.

    add_action('wpcf7_mail_sent', 'wpcf7_redirect_on_submit');
    function wpcf7_redirect_on_submit($wpcf7)
    {
    		wp_redirect( 'http://www.google.com' );
    		exit;
    }
    add_action('wpcf7_mail_sent', 'wpcf7_redirect_on_submit');
    function wpcf7_redirect_on_submit($wpcf7)
    {
    		header( 'Location: http://www.google.com' );
    		exit;
    }
  4. karpediem
    Member
    Posted 1 year ago #

    I have the same problem with tis code

    add_action("wpcf7_mail_sent", "wpcf7_do_insert_post");
    function wpcf7_do_insert_post($wpcf7) {
        var_dump($wpcf7);
        die();
    }

    I have tried with this
    add_action("wpcf7_before_send_mail", "wpcf7_do_insert_post");
    But it is same issue : I receive email but no confirmation messages after submission, the little spinning circle stays and no var_dump.

    Sorry, my English is not very good...

  5. allenmccabe
    Member
    Posted 1 year ago #

    I haven't tried this, but it looks like you need to delay the action adding. Check out http://stackoverflow.com/questions/3203043/extending-contact-form-7-wordpress-plugin-by-using-hooks

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic