Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a simple contact form using CONTACT FORM 7 PLUGIN on a page on my site. I want user to be able to download a video file only after he/she fills out the form and the form submission is successful. How do i check whether the form is successfully submitted so that I can then put in the code for force download of the file?

share|improve this question
add comment

migrated from stackoverflow.com Jun 20 '11 at 12:54

This question came from our site for professional and enthusiast programmers.

5 Answers

up vote 3 down vote accepted

In Additional Settings, use on_sent_ok: "location = 'http://example.com/';" to redirect to another page, but as said above, it's not that secure. You can hide the page via robots.txt.

share|improve this answer
add comment

You need some variable to let this page know if it's successful or not. With-in a conditional statement would go your link to download the video. This might involve a custom template page, or some sort of custom shortcode to implement.

You might name a variable like "$showVid".

from there , use the on_sent_ok: "location = 'http://example.com/'; where the 'example.com' is a dummy page ( for lack of better terms ) that simply redirects back to the contact form page, now with a POST variable in place.

Assign that variable to let you page know it's time to show the hyperlink.

$showVid = isset( $_POST['success'] );

*I'm not sure how to or if you can send POST data back with wp_redirect, perhaps that's another question that could be found/answered on here.*

Alternatively you might use a cookie to let your browser know.

now in doing this you still might want to do the redirect thing, but this time your not sending variable back from the dummy page, your just basically refreshing the page real quick, and then back with a cookie set.

now assign this same variable from the cookie.

$showVid = isset( $_COOKIE['success'] );

you conditional might be something such as :

if($showVid)  _( 'code for download link ' ) ;
share|improve this answer
add comment

You've probably gotten this all figured out by now, but for everyone else who visits this page... change the message for "# Sender's message was sent successfully" to be a link to your video. Simple, and ONLY displays if the sender submits the form.

share|improve this answer
add comment

If I remember correctly Contact Form 7 has the option to redirect to a success-page after the visitor clicks the submit-button.

Although you would have to make sure to hide that particular success-page from the rest of the site, in order to prevent people "accidentally" reaching that page, you could use that as a setup, as the only way reaching the success-page is after a successful form submission.

share|improve this answer
add comment

Well, i want a link to appear on the same page below the contact form after successful submission of the contact form. Link should say Download your video 'here' where 'here' should be a hyperlink clicking on which starts the force download of the video.

So i want to check whether form was successfully submitted and only then the download link should apper. How do i do this?

share|improve this answer
    
Your post is not an Answer, yet you posted as an answer. –  Rev. Voodoo Aug 9 '11 at 19:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.