• Hello,
    I haven’t messed with CF7 in awhile or wordpress really for that matter and I’ve gotten stuck on a couple of things..

    I’m using a custom theme but I added the following code for my registration page (Connects to MSSQL) on an external site to submit to another database..

    I use this filter to replace the cf7 form action:

    add_filter('wpcf7_form_action_url', 'wpcf7_custom_form_action_url');
    function wpcf7_custom_form_action_url($url)
    {
        global $post;
        $id_to_change = 19;
        if($post->ID === $id_to_change)
            return '?add=1';
        else
            return $url;
    }

    And I also include the php/mssql database code into the functions.php also.. I’ve also tried putting the code into the header.php..

    My problem is that, when I add the code to the header.php for mssql, the form, when submitted would appear to work.. And you get the thank you message if it passed the akismet check.. However, nothing is being created in the database.. When I add the code to the function.php file, submitting the form appears to hang.. The circle just keeps spinning.. But it creates the db account but then extra empty submissions..

    My form code, below the connection info looks like this:

    if($_GET['add'] == '1'){
    	$username = $_POST["acc-name"];
    	$pwd = $_POST["acc-passwd"];

    The cf7 form has a post that submits to ?add=1

    Seems like no matter what I try, I just can’t get the form to actually create the account in the external database even though cf7 appears to work fine..

    Am I going about this the wrong way?

    Thanks,
    Chris

    https://wordpress.org/plugins/contact-form-7/

  • The topic ‘Question if CF7 can actually do this?.. Posting to External DB?’ is closed to new replies.