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][1]][1]

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.

  [1]: https://i.sstatic.net/4cfwu.png