Wednesday, 15 April 2015

How to restrict people from visiting Download page except when submitting from Contact Form 7 (Wordpress Plugin)? -


I am working on a WordPress website. When we want to provide a download to all visitors, fill out the contact form. We want to restrict any other visit to the download link, except when it comes with contact form.

Currently I'm able to redirect the user to the download page. I submit using On_sent_ok: "location = '';; Advanced options in the Contact Form 7 interface.

However, I can reach the same page whenever I am not submitting the form. Is there a way to block people by visiting this page, except when they use the form? I would like to use the Contact Form 7 plugin within the WordPress framework for this purpose.

Definitely possible I hate personally when people share their contact information with me For some free downloads, I strongly advise you to make this alternative

But, because you really want to do this, I will just set some type - for URL Submit = the suffix of success, and if it exists, download link Ikhaan.

You can add your functions.php file to work for it ( edit: Adjust so that they can be reused for shortcode. ):

  // Obtain the current page URL and give it $ url_current = @ ($ _SERVER ["HTTPS "]! = 'On')? 'Http: //'.$_SERVER ["SERVER_NAME"]:' https: //'.$_SERVER ["SERVER_NAME"]; $ Url_current = ($ _SERVER ["SERVER_PORT"]! == 80)? ":". $ _ Server ["SERVER_PORT"]: ""; $ Url_current = $ _SERVER ["REQUEST_URI"]; $ Url_clean = array_shift (explosion ('?', $ Url_current)); $ Url_success = $ url_clean '? = 'Submit Success'; Function free_download ($ ATT) {// Remove variables (Shortcodes_ets (array ('contact_form' => gt; '', 'download_link' = & gt; ''), $ ATT); // modify the variable $ contact_form = do_shortcode ('['. $ Contact_form. ']'); If ($ url_current == $ url_success) {return $ download_link; } And {return $ contact_form; }} Add_shortcode ('free_download', 'free_download');   

In your Contact Form 7 settings, follow these instructions to set the appropriate guided link (with the same page, but? Submit = success suffix): < P> WP content editor, [free_download contact_form = 'contact-form-7 id = "12345" title = "whatever"' download_link = '& lt; P & gt; Use some message here to embed content & lt; A href = "http: //YOUR-DOWNLOAD-LINK.pdf" & gt; Download & lt; / A & gt; & Lt; / P & gt; '] shortcode

Now with this attitude, which is that? Submit = uses the success link, it still can get the content, so it's not really 100% secure, but it's unclear so that the average visitors can not get it.

No comments:

Post a Comment