Answers.Body: <p>Add a <a href="https://github.com/aelvan/Preparse-Field-Craft" rel="nofollow">Preparse field</a> to the entry type you're posting to and make it generate a random string on entry save.
  Then make the Guest Entries plugin redirect to a URL with that Preparse field's value in the query string.</p>
  
  <p><code>&lt;input type="hidden" name="redirect" value="success?id={id}&amp;key={preparseField}"&gt;</code></p>
  
  <p>You should now be able to get that entry model in your template and test against that Preparse field's value.</p>
  
  <pre><code>{% set query = craft.request.getQuery() %}
  {% set entry = craft.entries.id(query.id).preparseField(query.preparseField).first() %}
  
  {% if not entry %}
      {% exit 404 %}
  {% endif %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-02T12:04:39.970Z
Answers.Text: Hi @carlcs So basically this plugin pass a value set in preparse field setting page in CP to some model in front end only on entry save event? I've set some value with several characters to shuffle like this `{% set chars = '0123456789'|split('') %} {% set string = shuffle(chars)|join %} {{ string|slice(0, 5) }}` and saved it as preparse field with handle `secterKey`. On the front end everything is according to your answer in code except I changed `key={secretKey}` and `.preparseField(query.secretKey)`. I got error message that key `secretKey` doesn't exist.
Answers.UserDisplayName: Dominik Krulak
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-02T12:08:39.790Z
Answers.Text: I'm not even sure I proceed correctly because on entry form my URI looks like this `...success?id=123&key=`. I assume the string variable I set doesn't get passed to element model. Or I don't understand How it works. On plugin setting page both options are enabled. I think that doesn't effect it.
Answers.UserDisplayName: Dominik Krulak
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-04T12:11:30.820Z
Answers.Text: @dominik yeah, I forgot that the plugin saves Preparse fields after the element itself is saved. Have a look at my forked version of the plugin that has a "Parse before save" option added. https://github.com/carlcs/craft-preparsefield
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-04T19:48:07.163Z
Answers.Text: Thank you for your effort to update the plugin. That worked well. Upon successful form submission my URI looked like this `?id=422&key=097306`  but template got error with following message: **Key "secretKey" for array with keys "p, id, key" does not exist**. So I though I'm not accessing the actual string value but preparseField itself. So I ended up with `(query.string)` whereas it got passed through this error message but have encountered on another one. It can't access an attribute  `("attribute")` on a string variable `("422")` which is our `entry.id`. It seems to be a minor mistake
Answers.UserDisplayName: Dominik Krulak
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-24T07:45:18.607Z
Answers.Text: Hi @carlcs. Would it still work if we upload a file? The Preparse field seems to be break generating a `key` string (_remain blank_) on before entry save when a file is attached to form. I think it connects's to [this issue](https://github.com/aelvan/Preparse-Field-Craft/issues/9).
Answers.UserDisplayName: Dominik Krulak
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-24T16:30:45.913Z
Answers.Text: @dominik hmm.. so you are no longer using that fork of mine and updated to the latest Preparse plugin, and you have the "parse before save" option enabled in your field settings? Is this right?
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-25T06:02:19.133Z
Answers.Text: Yes @carlcs you're correct at all. I had to upgrade because there was some issue with PHP 5.3. And I didn't realise that I had your fork running up until your answer. I think during upgrade files were just merged together as "parse before save" option still live. This option isn't by default If I remember that. So I assume your code hasn't been overwritten when upgraded.
Answers.UserDisplayName: Dominik Krulak
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-25T06:07:38.077Z
Answers.Text: Alright so it's working again?
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-25T06:14:22.387Z
Answers.Text: It works as always do except when a file is sent over the form. A random string isn't generated in this case. It's get generated when I resave entry from back end.
Answers.UserDisplayName: Dominik Krulak
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-31T22:56:35.050Z
Answers.LastActivityDate: 2016-03-31T22:56:35.050Z
Answers.UserDisplayName: carlcs
Body: <p>I have redirect to a web page upon successful form submission using guest plugin. The redirected page is in announcement tone so I'd like to prevent it from direct access with exception that comes from form submission.</p>
  
  <p>Is there something Craft can do?</p>
  
Tags: <config>
Title: Prevent direct access to a web page except redirect
ThreadText: # Prevent direct access to a web page except redirect
  
  (Asked by: username_0 on 2016-03-31)
  
  I have redirect to a web page upon successful form submission using guest plugin. The redirected page is in announcement tone so I'd like to prevent it from direct access with exception that comes from form submission.
  
  Is there something Craft can do?
  
  **Tags:** config
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-03-31. Score: 3 | Accepted answer
  
  Add a [Preparse field](https://github.com/aelvan/Preparse-Field-Craft) to the entry type you're posting to and make it generate a random string on entry save.
  Then make the Guest Entries plugin redirect to a URL with that Preparse field's value in the query string.
  
  `<input type="hidden" name="redirect" value="success?id={id}&key={preparseField}">`
  
  You should now be able to get that entry model in your template and test against that Preparse field's value.
  
  ```
  {% set query = craft.request.getQuery() %}
  {% set entry = craft.entries.id(query.id).preparseField(query.preparseField).first() %}
  
  {% if not entry %}
      {% exit 404 %}
  {% endif %}
  
  ```
  
  > **Comments:**
  > **username_0**: Hi @username_1 So basically this plugin pass a value set in preparse field setting page in CP to some model in front end only on entry save event? I've set some value with several characters to shuffle like this `{% set chars = '0123456789'|split('') %} {% set string = shuffle(chars)|join %} {{ string|slice(0, 5) }}` and saved it as preparse field with handle `secterKey`. On the front end everything is according to your answer in code except I changed `key={secretKey}` and `.preparseField(query.secretKey)`. I got error message that key `secretKey` doesn't exist.  
  > **username_0**: I'm not even sure I proceed correctly because on entry form my URI looks like this `...success?id=123&key=`. I assume the string variable I set doesn't get passed to element model. Or I don't understand How it works. On plugin setting page both options are enabled. I think that doesn't effect it.  
  > **username_1**: @username_0 yeah, I forgot that the plugin saves Preparse fields after the element itself is saved. Have a look at my forked version of the plugin that has a "Parse before save" option added. https://github.com/username_1/craft-preparsefield  
  > **username_0**: Thank you for your effort to update the plugin. That worked well. Upon successful form submission my URI looked like this `?id=422&key=097306`  but template got error with following message: **Key "secretKey" for array with keys "p, id, key" does not exist**. So I though I'm not accessing the actual string value but preparseField itself. So I ended up with `(query.string)` whereas it got passed through this error message but have encountered on another one. It can't access an attribute  `("attribute")` on a string variable `("422")` which is our `entry.id`. It seems to be a minor mistake  
  > **username_0**: Hi @username_1. Would it still work if we upload a file? The Preparse field seems to be break generating a `key` string (_remain blank_) on before entry save when a file is attached to form. I think it connects's to [this issue](https://github.com/aelvan/Preparse-Field-Craft/issues/9).  
  > **username_1**: @username_0 hmm.. so you are no longer using that fork of mine and updated to the latest Preparse plugin, and you have the "parse before save" option enabled in your field settings? Is this right?  
  > **username_0**: Yes @username_1 you're correct at all. I had to upgrade because there was some issue with PHP 5.3. And I didn't realise that I had your fork running up until your answer. I think during upgrade files were just merged together as "parse before save" option still live. This option isn't by default If I remember that. So I assume your code hasn't been overwritten when upgraded.  
  > **username_1**: Alright so it's working again?  
  > **username_0**: It works as always do except when a file is sent over the form. A random string isn't generated in this case. It's get generated when I resave entry from back end.  
  
  ---
  
  