Answers.Body: <p>It turns out adding a '/' at the end of the Permalink Settings was made it work. I'm not sure how this ever worked.
  From</p>
  <pre><code>/%category%/%post_id%/%postname%
  </code></pre>
  <p>To</p>
  <pre><code>/%category%/%post_id%/%postname%/
  </code></pre>
  <p><a href="https://mysite.org/wp-admin/options-permalink.php" rel="nofollow noreferrer">https://mysite.org/wp-admin/options-permalink.php</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-06T15:45:18.837Z
Answers.LastActivityDate: 2021-10-06T15:45:18.837Z
Answers.UserDisplayName: James
Body: <p>after registering for an even using <strong>PayPal - Website Payments Standard</strong> (with the CiviCore processor) the transaction worked and email was fired but the user sees this instead of the thank you page.
  this is the visible error:
  <code>Sorry, due to an error, we are unable to fulfill your request at the moment. You may want to contact your administrator or service provider with more details about what action you were performing when this occurred. Could not find valid value for id</code></p>
  <p>using CiviCRM 5.41.2 on top of Wordpress 5.8.1
  the line in question seems to be:</p>
  <pre><code>$is_monetary = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $id, 'is_monetary');
  </code></pre>
  <p>$id is defined:</p>
  <pre><code>$id = CRM_Utils_Request::retrieve('id', 'Positive', $controller, TRUE);
  </code></pre>
  <p>stack:</p>
  <pre><code>Exception trace
  #   Function    Location
  0   CRM_Utils_Request::retrieve('id', 'Positive', Object(CRM_Event_Controller_Registration), true)  /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Event/StateMachine/Registration.php:27
  1   CRM_Event_StateMachine_Registration-&gt;__construct(Object(CRM_Event_Controller_Registration), true)   /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Event/Controller/Registration.php:27
  2   CRM_Event_Controller_Registration-&gt;__construct('Event Registrati…', true, 'null', null, 'false')    /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:308
  3   CRM_Core_Invoke::runItem(Array) /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:69
  4   CRM_Core_Invoke::_invoke(Array) /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:36
  5   CRM_Core_Invoke::invoke(Array)  /var/www/html/wp-content/plugins/civicrm/civicrm.php:1178
  6   CiviCRM_For_WordPress-&gt;invoke() /var/www/html/wp-content/plugins/civicrm/includes/civicrm.basepage.php:354
  7   CiviCRM_For_WordPress_Basepage-&gt;basepage_handler(Object(WP))    /var/www/html/wp-includes/class-wp-hook.php:303
  8   WP_Hook-&gt;apply_filters(null, Array) /var/www/html/wp-includes/class-wp-hook.php:327
  9   WP_Hook-&gt;do_action(Array)   /var/www/html/wp-includes/plugin.php:518
  10  do_action_ref_array('wp', Array)    /var/www/html/wp-includes/class-wp.php:763
  11  WP-&gt;main('')    /var/www/html/wp-includes/functions.php:1291
  12  wp()    /var/www/html/wp-blog-header.php:16
  13  require('/var/www/html/wp…')    /var/www/html/index.php:17
  14  {main}   
  Sorry, due to an error, we are unable to fulfill your request at the moment. You may want to contact your administrator or service provider with more details about what action you were performing when this occurred.
  Could not find valid value for id
  
  Return to home page.
  </code></pre>
  <p>logs: <a href="https://paste.ubuntu.com/p/fVWgvKK4cc/" rel="nofollow noreferrer">https://paste.ubuntu.com/p/fVWgvKK4cc/</a></p>
  <p>the link after registartion/paypal looks like <a href="https://example.org/civicrm/event/register?_qf_ThankYou_display=1&amp;qfKey=CRMEventControllerRegistrationNUMBERSANDLETTERS_NUMBERS&amp;PayerID=NUMBERSANDLETTERS" rel="nofollow noreferrer">https://example.org/civicrm/event/register?_qf_ThankYou_display=1&amp;qfKey=CRMEventControllerRegistrationNUMBERSANDLETTERS_NUMBERS&amp;PayerID=NUMBERSANDLETTERS</a></p>
  <p>the <strong>Test-drive</strong> works as expected.
  Example Link that works in test drive:
  <a href="https://example.org/wp-admin/admin.php?page=CiviCRM&amp;q=civicrm%2Fevent%2Fregister&amp;_qf_ThankYou_display=1&amp;qfKey=CRMEventControllerRegistrationNUMBERSANDLETTERS_NUMBERS&amp;PayerID=NUMBERSANDLETTERS" rel="nofollow noreferrer">https://example.org/wp-admin/admin.php?page=CiviCRM&amp;q=civicrm%2Fevent%2Fregister&amp;_qf_ThankYou_display=1&amp;qfKey=CRMEventControllerRegistrationNUMBERSANDLETTERS_NUMBERS&amp;PayerID=NUMBERSANDLETTERS</a>
  I'm not sure where to go from here.</p>
  <p>More logs!!! &quot;ID is:&quot; after each conditional in retrieve -&gt; CRM/Utils/Request.php<br />
  and more before the throw.</p>
  <pre><code>      error_log(&quot;_SESSION is: &quot; . print_R($_SESSION, true));
        error_log(&quot;_GET is: &quot; . print_R($_GET, true));
        error_log(&quot;_POST is: &quot; . print_R($_POST, true));
        error_log(&quot;_REQUEST is: &quot; . print_R($_REQUEST, true));
        error_log(&quot;_SERVER is: &quot; . print_R($_SERVER, true));
        error_log(&quot;ID is: &quot; . print_R($value, true));
  </code></pre>
  <p><a href="https://paste.ubuntu.com/p/sKd2Qkxknc/" rel="nofollow noreferrer">https://paste.ubuntu.com/p/sKd2Qkxknc/</a></p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-30T05:15:23.477Z
Comments.Text: you may need to add some info to your Q about your type of PayPal account and whether you are using core civi Payment Processor or eg Omnipay one. (not sure how PayPal gets set up so last point may be irrelevant)
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-30T07:40:26.090Z
Comments.Text: Check if a redirect is happening in before loading the thank you page. This is often the cause of this error message - i.e. loss of session data.
Comments.UserDisplayName: Christian Wach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-30T18:53:33.637Z
Comments.Text: Thank you @petednz-fuzion I updated the Q.
Comments.UserDisplayName: James
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-30T18:55:01.857Z
Comments.Text: @ChristianWach what other values do you expect to see in the query string?
Comments.UserDisplayName: James
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-30T19:11:25.973Z
Comments.Text: I don't think its missing a value in test drive it works but the link is different. I think it may be a route or WP vs CiviCRM thang.
  Example Link that works in testdrive: 
  https://example.org/wp-admin/admin.php?page=CiviCRM&q=civicrm%2Fevent%2Fregister&_qf_ThankYou_display=1&qfKey=CRMEventControllerRegistrationNUMBERSANDLETTERS_NUMBERS&PayerID=NUMBERSANDLETTERS
Comments.UserDisplayName: James
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-10-01T08:46:08.893Z
Comments.Text: @James The query string isn't the issue - the ID is stored in the session, which is cleared when CiviCRM loads the Thank You page. If there has been a redirect before loading the Thank You page, then the session will not have the ID. Try logging page loads in `wp-settings.php` and see if there's an unwanted one.
Comments.UserDisplayName: Christian Wach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-10-01T08:51:03.677Z
Comments.Text: FWIW these redirects sometimes happen because `redirect_canonical()` traps what it thinks is an invalid URL and redirects to the "fixed" URL. The result is a loss of session data. Finding out if there's a redirect has to be the first step in debugging this.
Comments.UserDisplayName: Christian Wach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-10-02T11:43:51.760Z
Comments.Text: @ChristianWach do you mean like this:
  
  Request:
  
  civicrm/event/register
  Query String:
  page_id=4&civiwp=CiviCRM&q=civicrm%2Fevent%2Fregister&reset=1&id=8
  
  Matched Rewrite Rule:
  ^civicrm/([^?]*)?
  
  Matched Rewrite Query:
  page_id=4&civiwp=CiviCRM&q=civicrm%2Fevent%2Fregister
Comments.UserDisplayName: James
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-10-02T13:55:22.527Z
Comments.Text: @James I'd log `$_REQUEST` in `wp-settings.php` (and pepper `redirect_canonical()` with logging code as well) to get a clear picture of what's occurring between submitting the payment and loading the Thank You page.
Comments.UserDisplayName: Christian Wach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-10-02T13:56:34.670Z
Comments.Text: The "Matched Rewrite Query" is to be expected if you're using Clean URLs. That's not a redirect - just WordPress unpacking the URL.
Comments.UserDisplayName: Christian Wach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-10-02T21:00:17.560Z
Comments.Text: @ChristianWach thanks for the continued support.
  Looks like they match to me. (minus the uneeded '/') 
  SERVER['REQUEST_URI']
  /civicrm/event/register/?_qf_ThankYou_display=1&qfKey=CRMEventControllerRegistration4b72im9i3toggscock08gkc0oww48coc0cckw00cg4sk4w0gg0_8730&PayerID=RWUXETELQXTNN
  redirect_url
  http://127.0.0.1:8080/civicrm/event/register?_qf_ThankYou_display=1&qfKey=CRMEventControllerRegistration4b72im9i3toggscock08gkc0oww48coc0cckw00cg4sk4w0gg0_8730&PayerID=RWUXETELQXTNN
Comments.UserDisplayName: James
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-10-02T21:27:23.203Z
Comments.Text: how does the ID get on the request?
  (
      [_qf_ThankYou_display] => 1
      [qfKey] => CRMEventControllerRegistration4b72im9i3toggscock08gkc0oww48coc0cckw00cg4sk4w0gg0_2895
      [PayerID] => RWUXETELQXTNN
      [q] => civicrm/event/register
      [civiwp] => CiviCRM
      [noheader] => 1
  )
Comments.UserDisplayName: James
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-10-04T07:42:58.157Z
Comments.Text: "how does the ID get on the request?"
  
  It's stored in the session.
  
  I get the impression that you're focussing on the contents of one page load rather than tracking the sequence of page loads between the payment and Thank You page. I recommend focussing on that instead.
Comments.UserDisplayName: Christian Wach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-10-06T04:21:13.083Z
Comments.Text: it has the id in the seesion before the redirect from 
  
  /civicrm/event/register/?_qf_ThankYou_display....
  to
  /civicrm/event/register?_qf_ThankYou_display....
  but not after.
Comments.UserDisplayName: James
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-10-06T04:28:02.070Z
Comments.Text: (301 Moved Permanently)
Comments.UserDisplayName: James
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-10-06T04:34:34.317Z
Comments.Text: how do I keep WP from redirecting? or civicrm from adding the extra / at the end before the query string.
Comments.UserDisplayName: James
Tags: <civievent><paypal>
Title: Could not find valid value for id for event thankyou
ThreadText: # Could not find valid value for id for event thankyou
  
  (Asked by: username_0 on 2021-09-29)
  
  after registering for an even using **PayPal - Website Payments Standard** (with the CiviCore processor) the transaction worked and email was fired but the user sees this instead of the thank you page.
  this is the visible error:
  `Sorry, due to an error, we are unable to fulfill your request at the moment. You may want to contact your administrator or service provider with more details about what action you were performing when this occurred. Could not find valid value for id`
  
  using CiviCRM 5.41.2 on top of Wordpress 5.8.1
  the line in question seems to be:
  
  ```
  $is_monetary = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $id, 'is_monetary');
  
  ```
  
  $id is defined:
  
  ```
  $id = CRM_Utils_Request::retrieve('id', 'Positive', $controller, TRUE);
  
  ```
  
  stack:
  
  ```
  Exception trace
  #   Function    Location
  0   CRM_Utils_Request::retrieve('id', 'Positive', Object(CRM_Event_Controller_Registration), true)  /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Event/StateMachine/Registration.php:27
  1   CRM_Event_StateMachine_Registration->__construct(Object(CRM_Event_Controller_Registration), true)   /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Event/Controller/Registration.php:27
  2   CRM_Event_Controller_Registration->__construct('Event Registrati…', true, 'null', null, 'false')    /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:308
  3   CRM_Core_Invoke::runItem(Array) /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:69
  4   CRM_Core_Invoke::_invoke(Array) /var/www/html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:36
  5   CRM_Core_Invoke::invoke(Array)  /var/www/html/wp-content/plugins/civicrm/civicrm.php:1178
  6   CiviCRM_For_WordPress->invoke() /var/www/html/wp-content/plugins/civicrm/includes/civicrm.basepage.php:354
  7   CiviCRM_For_WordPress_Basepage->basepage_handler(Object(WP))    /var/www/html/wp-includes/class-wp-hook.php:303
  8   WP_Hook->apply_filters(null, Array) /var/www/html/wp-includes/class-wp-hook.php:327
  9   WP_Hook->do_action(Array)   /var/www/html/wp-includes/plugin.php:518
  10  do_action_ref_array('wp', Array)    /var/www/html/wp-includes/class-wp.php:763
  11  WP->main('')    /var/www/html/wp-includes/functions.php:1291
  12  wp()    /var/www/html/wp-blog-header.php:16
  13  require('/var/www/html/wp…')    /var/www/html/index.php:17
  14  {main}   
  Sorry, due to an error, we are unable to fulfill your request at the moment. You may want to contact your administrator or service provider with more details about what action you were performing when this occurred.
  Could not find valid value for id
  
  Return to home page.
  
  ```
  
  logs: <https://paste.ubuntu.com/p/fVWgvKK4cc/>
  
  the link after registartion/paypal looks like <https://example.org/civicrm/event/register?_qf_ThankYou_display=1&qfKey=CRMEventControllerRegistrationNUMBERSANDLETTERS_NUMBERS&PayerID=NUMBERSANDLETTERS>
  
  the **Test-drive** works as expected.
  Example Link that works in test drive:
  <https://example.org/wp-admin/admin.php?page=CiviCRM&q=civicrm%2Fevent%2Fregister&_qf_ThankYou_display=1&qfKey=CRMEventControllerRegistrationNUMBERSANDLETTERS_NUMBERS&PayerID=NUMBERSANDLETTERS>
  I'm not sure where to go from here.
  
  More logs!!! "ID is:" after each conditional in retrieve -> CRM/Utils/Request.php  
  and more before the throw.
  
  ```
        error_log("_SESSION is: " . print_R($_SESSION, true));
        error_log("_GET is: " . print_R($_GET, true));
        error_log("_POST is: " . print_R($_POST, true));
        error_log("_REQUEST is: " . print_R($_REQUEST, true));
        error_log("_SERVER is: " . print_R($_SERVER, true));
        error_log("ID is: " . print_R($value, true));
  
  ```
  
  <https://paste.ubuntu.com/p/sKd2Qkxknc/>
  
  **Tags:** civievent, paypal
  
  > **Comments:**
  > **username_1**: you may need to add some info to your Q about your type of PayPal account and whether you are using core civi Payment Processor or eg Omnipay one. (not sure how PayPal gets set up so last point may be irrelevant)  
  > **username_2**: Check if a redirect is happening in before loading the thank you page. This is often the cause of this error message - i.e. loss of session data.  
  > **username_0**: Thank you @username_1 I updated the Q.  
  > **username_0**: @username_2 what other values do you expect to see in the query string?  
  > **username_0**: I don't think its missing a value in test drive it works but the link is different. I think it may be a route or WP vs CiviCRM thang. Example Link that works in testdrive:  https://example.org/wp-admin/admin.php?page=CiviCRM&q=civicrm%2Fevent%2Fregister&_qf_ThankYou_display=1&qfKey=CRMEventControllerRegistrationNUMBERSANDLETTERS_NUMBERS&PayerID=NUMBERSANDLETTERS  
  > **username_2**: @username_0 The query string isn't the issue - the ID is stored in the session, which is cleared when CiviCRM loads the Thank You page. If there has been a redirect before loading the Thank You page, then the session will not have the ID. Try logging page loads in `wp-settings.php` and see if there's an unwanted one.  
  > **username_2**: FWIW these redirects sometimes happen because `redirect_canonical()` traps what it thinks is an invalid URL and redirects to the "fixed" URL. The result is a loss of session data. Finding out if there's a redirect has to be the first step in debugging this.  
  > **username_0**: @username_2 do you mean like this:  Request:  civicrm/event/register Query String: page_id=4&civiwp=CiviCRM&q=civicrm%2Fevent%2Fregister&reset=1&id=8  Matched Rewrite Rule: ^civicrm/([^?]*)?  Matched Rewrite Query: page_id=4&civiwp=CiviCRM&q=civicrm%2Fevent%2Fregister  
  > **username_2**: @username_0 I'd log `$_REQUEST` in `wp-settings.php` (and pepper `redirect_canonical()` with logging code as well) to get a clear picture of what's occurring between submitting the payment and loading the Thank You page.  
  > **username_2**: The "Matched Rewrite Query" is to be expected if you're using Clean URLs. That's not a redirect - just WordPress unpacking the URL.  
  > **username_0**: @username_2 thanks for the continued support. Looks like they match to me. (minus the uneeded '/')  SERVER['REQUEST_URI'] /civicrm/event/register/?_qf_ThankYou_display=1&qfKey=CRMEventControllerRegistration4b72im9i3toggscock08gkc0oww48coc0cckw00cg4sk4w0gg0_8730&PayerID=RWUXETELQXTNN redirect_url http://127.0.0.1:8080/civicrm/event/register?_qf_ThankYou_display=1&qfKey=CRMEventControllerRegistration4b72im9i3toggscock08gkc0oww48coc0cckw00cg4sk4w0gg0_8730&PayerID=RWUXETELQXTNN  
  > **username_0**: how does the ID get on the request? (     [_qf_ThankYou_display] => 1     [qfKey] => CRMEventControllerRegistration4b72im9i3toggscock08gkc0oww48coc0cckw00cg4sk4w0gg0_2895     [PayerID] => RWUXETELQXTNN     [q] => civicrm/event/register     [civiwp] => CiviCRM     [noheader] => 1 )  
  > **username_2**: "how does the ID get on the request?"  It's stored in the session.  I get the impression that you're focussing on the contents of one page load rather than tracking the sequence of page loads between the payment and Thank You page. I recommend focussing on that instead.  
  > **username_0**: it has the id in the seesion before the redirect from   /civicrm/event/register/?_qf_ThankYou_display.... to /civicrm/event/register?_qf_ThankYou_display.... but not after.  
  > **username_0**: (301 Moved Permanently)  
  > **username_0**: how do I keep WP from redirecting? or civicrm from adding the extra / at the end before the query string.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2021-10-06. Score: 0 | Accepted answer
  
  It turns out adding a '/' at the end of the Permalink Settings was made it work. I'm not sure how this ever worked.
  From
  
  ```
  /%category%/%post_id%/%postname%
  
  ```
  
  To
  
  ```
  /%category%/%post_id%/%postname%/
  
  ```
  
  <https://mysite.org/wp-admin/options-permalink.php>
  
  
  ---
  
  