Answers.Body: <p>Finally solved this one... The Nginx conf was doing a &quot;Drupally&quot; rewrite which was upsetting WordPress.</p>
  <p>try_files was appending args in this way:-</p>
  <pre><code>try_files $uri $uri/ /index.php?q=$uri&amp;$args;
  </code></pre>
  <p>And the correct WordPress way:-</p>
  <pre><code>try_files $uri $uri/ /index.php?$args;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-11-08T13:44:16.670Z
Answers.LastActivityDate: 2023-11-08T13:44:16.670Z
Answers.UserDisplayName: Darren
Body: <p>We've checked the CiviCRM base page (/civicrm), clean URLs enabled, permalinks set to /%postname%/ and CMS integration settings in Civi System Settings are correct.</p>
  <p>The &quot;Register&quot; button on the event info page is clicked, rather than a shortcode embedded in  a Wordpress page.</p>
  <p>Event registration completes but the &quot;Thank You&quot; message configured in the Event settings is not shown (Amounts section and Confirmation page are both disabled as these are free events).</p>
  <pre><code>$Fatal Error Details = array:3 [
    &quot;message&quot; =&gt; &quot;Could not find valid value for id&quot;
    &quot;code&quot; =&gt; null
    &quot;exception&quot; =&gt; CRM_Core_Exception {#3586
      -errorData: array:1 [
        &quot;error_code&quot; =&gt; 0
      ]
      #cause: null
      -_trace: null
      #message: &quot;Could not find valid value for id&quot;
      #code: 0
      #file: &quot;/var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Utils/Request.php&quot;
      #line: 98
      trace: {
        /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Utils/Request.php:98 {
          CRM_Utils_Request::retrieve($name, $type, $store = null, $abort = false, $default = null, $method = 'REQUEST')
          › if (!isset($value) &amp;&amp; $abort) {
          ›   throw new CRM_Core_Exception(ts('Could not find valid value for %1', [1 =&gt; $name]));
          › }
        }
        /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Event/StateMachine/Registration.php:27 { …}
        /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Event/Controller/Registration.php:27 { …}
        /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:314 { …}
        /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:69 { …}
        /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:36 { …}
        /var/www/html/wp-content/plugins/civicrm/civicrm.php:1199 { …}
        /var/www/html/wp-content/plugins/civicrm/includes/civicrm.basepage.php:380 { …}
        /var/www/html/wp-includes/class-wp-hook.php:308 { …}
        /var/www/html/wp-includes/class-wp-hook.php:332 { …}
        /var/www/html/wp-includes/plugin.php:565 { …}
        /var/www/html/wp-includes/class-wp.php:797 { …}
        /var/www/html/wp-includes/functions.php:1334 { …}
        /var/www/html/wp-blog-header.php:16 { …}
        /var/www/html/index.php:17 { …}
      }
    }
  ]
  </code></pre>
  <p>Looking at the redirects below, the browser session is lost. WordPress seems to be doing something to the URL as it has double slashes:-</p>
  <p><a href="https://i.sstatic.net/4cfwu.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/4cfwu.png" alt="redirects" /></a></p>
  <p>So the form is posted to:</p>
  <p>https://localhost/civicrm//event/register//</p>
  <p>302 redirects to:</p>
  <p>https://localhost/civicrm//event/register//?_qf_ThankYou_display=true&amp;qfKey=CRMEventControllerRegistration2ue2o3j19k2so0g0sowg8swgcs0w0c8k0kkw404osg8kkwc884_2058</p>
  <p>Seems like WordPress does not like the double slash and does something with redirect_canonical() which forces another redirect</p>
  <p>301 redirects to:</p>
  <p>https://localhost/civicrm/event/register/?_qf_ThankYou_display=true&amp;qfKey=CRMEventControllerRegistration2ue2o3j19k2so0g0sowg8swgcs0w0c8k0kkw404osg8kkwc884_2058</p>
  <p>by this time, the session ID has gone and we get could not find value for id.</p>
  
Tags: <wordpress><civievent><nginx>
Title: Event Registration Error on Wordpress 6.3.1 Civi 5.63.4 "Could not find valid value for id"
ThreadText: # Event Registration Error on Wordpress 6.3.1 Civi 5.63.4 "Could not find valid value for id"
  
  (Asked by: username_0 on 2023-10-19)
  
  We've checked the CiviCRM base page (/civicrm), clean URLs enabled, permalinks set to /%postname%/ and CMS integration settings in Civi System Settings are correct.
  
  The "Register" button on the event info page is clicked, rather than a shortcode embedded in a Wordpress page.
  
  Event registration completes but the "Thank You" message configured in the Event settings is not shown (Amounts section and Confirmation page are both disabled as these are free events).
  
  ```
  $Fatal Error Details = array:3 [
    "message" => "Could not find valid value for id"
    "code" => null
    "exception" => CRM_Core_Exception {#3586
      -errorData: array:1 [
        "error_code" => 0
      ]
      #cause: null
      -_trace: null
      #message: "Could not find valid value for id"
      #code: 0
      #file: "/var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Utils/Request.php"
      #line: 98
      trace: {
        /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Utils/Request.php:98 {
          CRM_Utils_Request::retrieve($name, $type, $store = null, $abort = false, $default = null, $method = 'REQUEST')
          › if (!isset($value) && $abort) {
          ›   throw new CRM_Core_Exception(ts('Could not find valid value for %1', [1 => $name]));
          › }
        }
        /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Event/StateMachine/Registration.php:27 { …}
        /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Event/Controller/Registration.php:27 { …}
        /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:314 { …}
        /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:69 { …}
        /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:36 { …}
        /var/www/html/wp-content/plugins/civicrm/civicrm.php:1199 { …}
        /var/www/html/wp-content/plugins/civicrm/includes/civicrm.basepage.php:380 { …}
        /var/www/html/wp-includes/class-wp-hook.php:308 { …}
        /var/www/html/wp-includes/class-wp-hook.php:332 { …}
        /var/www/html/wp-includes/plugin.php:565 { …}
        /var/www/html/wp-includes/class-wp.php:797 { …}
        /var/www/html/wp-includes/functions.php:1334 { …}
        /var/www/html/wp-blog-header.php:16 { …}
        /var/www/html/index.php:17 { …}
      }
    }
  ]
  
  ```
  
  Looking at the redirects below, the browser session is lost. WordPress seems to be doing something to the URL as it has double slashes:-
  
  [![redirects](https://i.sstatic.net/4cfwu.png)](https://i.sstatic.net/4cfwu.png)
  
  So the form is posted to:
  
  https://localhost/civicrm//event/register//
  
  302 redirects to:
  
  https://localhost/civicrm//event/register//?\_qf\_ThankYou\_display=true&qfKey=CRMEventControllerRegistration2ue2o3j19k2so0g0sowg8swgcs0w0c8k0kkw404osg8kkwc884\_2058
  
  Seems like WordPress does not like the double slash and does something with redirect\_canonical() which forces another redirect
  
  301 redirects to:
  
  https://localhost/civicrm/event/register/?\_qf\_ThankYou\_display=true&qfKey=CRMEventControllerRegistration2ue2o3j19k2so0g0sowg8swgcs0w0c8k0kkw404osg8kkwc884\_2058
  
  by this time, the session ID has gone and we get could not find value for id.
  
  **Tags:** wordpress, civievent, nginx
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2023-11-08. Score: 2 | Accepted answer
  
  Finally solved this one... The Nginx conf was doing a "Drupally" rewrite which was upsetting WordPress.
  
  try\_files was appending args in this way:-
  
  ```
  try_files $uri $uri/ /index.php?q=$uri&$args;
  
  ```
  
  And the correct WordPress way:-
  
  ```
  try_files $uri $uri/ /index.php?$args;
  
  ```
  
  
  ---
  
  