简体   繁体   中英

form action in contact form 7 wordpress

Im using Contact Form 7 and upon submitting I am redirecting to another page. Im looking to set a session variable so that when I get to the new page it can check if the form has been submitted or not. It means that if you arrive on that page from elsewhere (as opposed to the form) it wont allow you see certain download links.

My issue is that I cant seem to pass on the $_POST . Im unsure where to set the variable. within the Contact form 7 plugin.

Here is the output of the form...

<form action="/downloads/#wpcf7-f127-p124-o1" method="post" class="wpcf7-form" novalidate="novalidate">

<div style="display: none;">

<input type="hidden" name="_wpcf7" value="127" />
<input type="hidden" name="_wpcf7_version" value="3.4" />
<input type="hidden" name="_wpcf7_unit_tag" value="wpcf7-f127-p124-o1" />
<input type="hidden" name="_wpnonce" value="211b6bff7f" />

</div>

<p>Your Name (required)<br />

<span class="wpcf7-form-control-wrap your-name"><input type="text" name="your-name" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required" aria-required="true" /></span> </p>

<p>Your Email (required)<br />

<span class="wpcf7-form-control-wrap your-email"><input type="email" name="your-email" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-email wpcf7-validates-as-required wpcf7-validates-as-email" aria-required="true" /></span> </p>

<p><input type="submit" value="Send" class="wpcf7-form-control wpcf7-submit" /></p>

<div class="wpcf7-response-output wpcf7-display-none"></div>

</form>

Here is the code I would like implement

 if(isset($_POST['your-email'])){          

         $_SESSION['user_email_set'] = true;
}

The problem is I cant figure out where that action is going to as it seems to just point back to itself, and the $_POST doesnt seem to show anything.

(Ive even tried print_r($_POST); on the same page and turned off the redirect and it still doesnt display anything)

Thank you

Check this Mini Guide about Contact Form 7.

It has section about using posted Form Data in Server Side Instead of Mailing which has this code:

add_action("wpcf7_before_send_mail", "wpcf7_do_something_else");  

function wpcf7_do_something_else(&$wpcf7_data) {  

    // Here is the variable where the data are stored!  
    var_dump($wpcf7_data);  

    // If you want to skip mailing the data, you can do it...  
    $wpcf7_data->skip_mail = true;  

}  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM