• I’ve read all the posts but can not find anything that does what I want to do … and it’s simple!

    I just want to make a very small update to the wp-usermeta table that relates to the user that has just filled out the form. It appears that the Additional Settings area is dedicated to javascript, which is Hebrew to me. Is there some way I can execute a PHP (specifically, a wpdb statement) at this point? I know who is logged on and I know the other piece of info I want to store (from the form) – I just want to do it, with out major hacking … or having to use the DB extension (it builds it’s own table and does all sorts of stuff I don’t want to do – so I’d have to hack it too).

    I thought about calling another page from the Additional Setting section using the sample “on_sent_ok” hook but I don’t know how to send variables to the redirected page, like this?

    on_sent_ok: “location.replace(‘http://www.YOURSITE.com?var1=fred&var2=joe’);”,

    where fred and joe are fields (some special-mail-tags) from the form
    being submitted. There must be an easy way to do this that doesn’t require chopping in to the code (I tried for an hour with this little baby …

    add_action(‘wpcf7_before_send_mail’, array(&$this, ‘theFunction’));

    but I couldn’t get it to work (and I broke the form).

    Has anyone done anything like what I want to do?

    Dave

Viewing 2 replies - 1 through 2 (of 2 total)
  • I think is impossible do directly what you want.

    I need the same, and I solved in this way:

    First of all I have created a form in the template file that contain the form generated by Contact Form (in my case in the page.php file). This form is something like this:

    <form action="http://www.mysite.com/target-page/" method="post" id="myform">
    <input name="variable_one" id="variable_one" type="hidden" value="" />
    <input name="variable_two" id="variable_two" type="hidden" value="" />
    </form>

    Then in the same file I’ve created 1 javascript functions:

    function gototarget() {
    document.getElementById('variable_one').value = document.val_one;
    document.getElementById('variable_two').value = document.val_two;
    document.getElementById('myform').submit();
    }

    Then in the same file I use jquery to set document variable from form input:

    $('#contactforminput1').change(function() {
    document.val_one = $(this).val();
    });
    $('#contactforminput2').change(function() {
    document.val_two = $(this).val();
    });

    Finally I’ve added in the Contact Form setting

    on_sent_ok: 'gototarget();'

    In this way, when a user set values in the form generated by Contact Form, jquery set 2 document variables.
    When form is submitted gototarget() function is called and values from document variables are putted in the hidden fields of my form and submitting this one I pass variables to target page.

    Instead of using the Additional Settings you could try the wpcf7_before_send_mail functions

    Check out http://wordpress.org/support/topic/plugin-contact-form-7-cf7-posted_data-checkbox-fields

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Contact Form 7] Execute PHP at "on_sent_ok" time’ is closed to new replies.