Answers.Body: <p>I stumbled on this issue on CiviCRM 5.44 sites on WordPress, and the issue was that the site did not have &quot;Clean URLs&quot; enabled, since it was using an old civicrm.settings.php.</p>
  <p>Make sure that the civicrm.settings.php has this bit of code:</p>
  <pre><code>  if (!defined('CIVICRM_CLEANURL')) {
      if ( function_exists('variable_get') &amp;&amp; variable_get('clean_url', '0') != '0') {
        define('CIVICRM_CLEANURL', 1 );
      }
      elseif ( function_exists('config_get') &amp;&amp; config_get('system.core', 'clean_url') != 0) {
        define('CIVICRM_CLEANURL', 1 );
      }
      elseif( function_exists('get_option') &amp;&amp; get_option('permalink_structure') != '' ) {
        define('CIVICRM_CLEANURL', 1 );
      }
      else {
        define('CIVICRM_CLEANURL', 0);
      }
    }
  </code></pre>
  <p>and then in WordPress permalink settings, make sure that it uses the &quot;post name&quot; to form permalinks (this might not be strictly necessary according to docs, but I found that it helps), and save the permalinks setting form, so that the permalink cache is flushed.</p>
  <p>Finally, Event Registration pages will be accessible using URLs that look like:</p>
  <p><a href="https://example.org/civicrm/event/register/?id=123&amp;reset=1" rel="noreferrer">https://example.org/civicrm/event/register/?id=123&amp;reset=1</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-03T20:26:23.307Z
Answers.LastActivityDate: 2022-01-03T20:26:23.307Z
Answers.UserDisplayName: bgm
Answers.Body: <p>I was having a similar problem. I noticed the base url for WordPress was not set. </p>
  
  <p>If you haven't set that, try setting that in <strong>Administer > CMS Database Integration</strong> and let us know if that fixed your issue.</p>
  
  <p>Make sure the event is not the home page, that seems to cause problems with the base url. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-21T21:01:49.330Z
Answers.Text: It's called a "base page" actually.  And the second step of this configuration is to actually create a WP page with this URL.  For instance if your base page is "civi" your WP page must have the permalink of "civi" as well.  See my post below for screenshots
Answers.UserDisplayName: CiviTeacher
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-22T07:59:36.063Z
Answers.Text: I misunderstood your answer, Sanjay Jain. I noticed it was set to the base URL of the website, so I thought that was okay. CiviTeacher cleared this up now and will try this solution! Thanks for your help!
Answers.UserDisplayName: user825
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-08T19:19:54.817Z
Answers.LastActivityDate: 2015-09-11T11:51:51.830Z
Answers.LastEditDate: 2015-09-11T11:51:51.830Z
Answers.UserDisplayName: Sanjay Jain
Answers.Body: <p>On 4.7.9 + WP 4.5.3 I had this problem.</p>
  
  <p>I have a paid event, with PayPal as payment processor, but also the Pay Later option is enabled.</p>
  
  <p>Registrations proceed fine when paid with PayPal.  I only get this error when a user ticks the Pay Later option.</p>
  
  <p>I tried using a WP shortcode as CiviTeacher mentioned but that did not work.  I <em>had</em> to set a Base Page - i.e., Administer | System Settings | CMS Database Integration could not be blank.  </p>
  
  <p>It doesn't have to be civicrm, it can be anything you want.  You can use <a href="http://www.domain.org/event" rel="nofollow">http://www.domain.org/event</a> or something similar.  </p>
  
  <p>Then you have to create a Page in WordPress with this URL as the permalink. I then put the event shortcode on this page and it works great!</p>
  
  <p>In my case I then set up an intro page at <a href="http://www.domain.org/" rel="nofollow">http://www.domain.org/</a> with a "Registration" link to <a href="http://www.domain.org/event" rel="nofollow">http://www.domain.org/event</a>.  </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-27T15:57:19.060Z
Answers.LastActivityDate: 2016-07-27T15:57:19.060Z
Answers.UserDisplayName: Jason
Answers.Body: <p>If you upgrade from CiviCRM &lt; 4.6, and have a WP frontend with links to Civicrm pages (e.g. an event calendar) that are full URLs, you'll need to edit those links: from '<a href="http://example.com/?page=Civicrm" rel="nofollow noreferrer">http://example.com/?page=Civicrm</a>...' to '<a href="http://example.com/civicrm/?page=Civicrm" rel="nofollow noreferrer">http://example.com/civicrm/?page=Civicrm</a>...'  to get the basepage.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-10T15:59:42.847Z
Answers.LastActivityDate: 2017-08-10T15:59:42.847Z
Answers.UserDisplayName: Lesley Evensen
Answers.Body: <p>I had this problem intermittently for some time when embedding event registration forms using a Wordpress shortcode. It has to do with page caching. CiviCRM parses the shortcode to capture the event ID and adds the id value to the global $_GET object. If the page is loaded from cache (usually when the back/forward button is pressed) the code that parses the shortcode does not run, and the event ID is not added to $_GET.</p>
  <p>I was able to fix this issue by making a page cache exception with the caching plugin I'm using.</p>
  <p>I think this behavior is essentially a bug and CiviCRM should output a hidden form variable with the event ID so that it still gets passed to the &quot;Thank You&quot; page if the registration form is loaded from cache.</p>
  <p>This is where Civi parses the shortcode and assigns the environment vars:
  civicrm/includes/civicrm.shortcode.php:</p>
  <pre><code>// Preprocess shortcode attributes.
  $args = $this-&gt;preprocess_atts($atts);
  
  // Sanity check for improperly constructed shortcode.
  if ($args === FALSE) {
    return '&lt;p&gt;' . __('Do not know how to handle this shortcode.', 'civicrm') . '&lt;/p&gt;';
  }
  
  // invoke() requires environment variables to be set.
  foreach ($args as $key =&gt; $value) {
    if ($value !== NULL) {
      set_query_var($key, $value);
      $_REQUEST[$key] = $_GET[$key] = $value;
    }
  }
  </code></pre>
  <p>Here are 3 solutions that are verified working:</p>
  <p><strong>1) Use the &quot;civicrm_buildForm&quot; hook with a template Region to add a custom template to Event Registration and Contribution forms (recommended).</strong></p>
  <pre><code>add_action( 'civicrm_buildForm', 'onBeforeFormBuilt' );
  
  function onBeforeFormBuilt($formName) {
      $formSubmitMap = array(
          'CRM_Contribute_Form_Contribution_Main' =&gt; array('contribution-main-not-you-block', 'CRM/Custom/ContributionFormId.tpl'),
          'CRM_Event_Form_Registration_Register' =&gt; array('event-register-not-you-block', 'CRM/Custom/EventFormId.tpl')
      );
      
      if ( in_array($formName, array_keys($formSubmitMap)) ) {
          $formType = $formSubmitMap[$formName];
      
          CRM_Core_Region::instance($formType[0])-&gt;add(array(
              'template' =&gt; $formType[1],
          ));
      }
  }
  
  </code></pre>
  <p>Contents of ContributionFormId.tpl:</p>
  <pre><code>&lt;input type=&quot;hidden&quot; name=&quot;id&quot; value=&quot;{$contributionPageID}&quot;&gt;
  </code></pre>
  <p>Contents of EventFormId.tpl:</p>
  <pre><code>&lt;input type=&quot;hidden&quot; name=&quot;id&quot; value=&quot;{$event.id}&quot;&gt;
  </code></pre>
  <p><strong>2) Modify core code (not recommended).</strong></p>
  <p>If you want to allow your registration page to be cached and you're willing to modify Core code, here is a quick hack:
  civicrm/CRM/Core/Form.php (after qfKey section):</p>
  <pre><code>if (isset($_REQUEST['id'])) {
      $this-&gt;addElement('hidden', 'id', $_REQUEST['id']); }
  }
  </code></pre>
  <p><strong>3) Use Javascript to perform a hard reload when the page is loaded from cache (not recommended).</strong></p>
  <pre><code>function purgeCache() {
      if ( function_exists('has_tag') &amp;&amp; function_exists('get_the_id') &amp;&amp; has_tag('logged-in-no-cache', get_the_id()) ) {
          // If this page has a tag &quot;no-cache&quot;, force browser to NOT load from cache
          $currQs = parsedUrl()['query'];
  
          echo &quot;
          &lt;script&gt;
              // Back buttom was pressed prior to loading this page
              if (window.performance) {
                  if (window.performance.navigation.type === 2) {
                      location.reload(true);
                  }
              // Use History to force cache purge
              } else if (window.history &amp;&amp; history.pushState) {
                  history.pushState('page-load', '', '&quot; . (!empty($currQs) ? $currQs . '&amp;' : '?') . &quot;w3tc_flush_post&amp;post_id=&quot; . get_the_id() . &quot;');
              }
          &lt;/script&gt;&quot;;
      }
  }
  </code></pre>
  <p>I haven't verified the history.pushState approach, but it should work OK.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-13T19:43:49.777Z
Answers.LastActivityDate: 2022-01-10T17:57:02.573Z
Answers.LastEditDate: 2022-01-10T17:57:02.573Z
Answers.UserDisplayName: dsmith63
Answers.Body: <p>I'm not sure of the cause, but I have a workaround. I'm guessing that you are using the direct link that Civi tells you to copy and paste from the event management page. Using that gives me the error too. However I created a WP page, embedded the event registration as a shortcode, and made it through registration and confirmation without errors.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-19T09:29:06.680Z
Answers.Text: But when you embed the registration form with  a shortcode, you have to specify the event to show the form for, right?
  
  To give a little more insight, I created a custom shortcode that lists CiviEvents. When you click on one of these events, you'll go to the event detailpage, which is the default page from Civi that I overwrite in the custom templates folder. On this page I use the URL to the registration page that is also used in the default page from Civi.
Answers.UserDisplayName: user825
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-19T00:37:44.327Z
Answers.LastActivityDate: 2015-08-19T00:37:44.327Z
Answers.UserDisplayName: Nicholai
Answers.Body: <p>This is a bit of "surprise" but essentially for 4.6 and beyond Civi event registration for Wordpress won't work unless you either 1) use a 'base page' or a 2) WP short code</p>
  
  <p>Solution #1 has two steps.</p>
  
  <ol>
  <li>create a WP page with the 'civicrm' permalink</li>
  <li>set a 'base page' within CiviCRM</li>
  </ol>
  
  <p>See attached images.</p>
  
  <p><a href="https://i.sstatic.net/Glz22.png" rel="noreferrer"><img src="https://i.sstatic.net/Glz22.png" alt="new page"></a></p>
  
  <p><a href="https://i.sstatic.net/Lc8Gx.png" rel="noreferrer"><img src="https://i.sstatic.net/Lc8Gx.png" alt="base page"></a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-22T07:53:38.680Z
Answers.Text: Thanks for your answer! Just checked and apparently I don't have a base page set. So will definitely try that, but at this point I already downgraded to Civi 4.4.19 (LTS), since on this version the registration works. I'm hoping to upgrade somewhere in the near future. Thanks!
Answers.UserDisplayName: user825
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-24T19:22:14.643Z
Answers.Text: We finally made time to test this answer (since we were upgrading Civi) and it works! It is worth mentioning though that my initial question was about Civi 4.6.4 and I tested this answer when I was already updated to 4.7.6.
Answers.UserDisplayName: user825
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-21T20:47:08.410Z
Answers.LastActivityDate: 2015-09-21T21:02:44.883Z
Answers.LastEditDate: 2015-09-21T21:02:44.883Z
Answers.UserDisplayName: CiviTeacher
Body: <p>This is my first question on a stackexchange-like website, so bare with if I fail to mention something important about my question.</p>
  
  <p><strong>The situation</strong></p>
  
  <p>At the moment, I’m working on my very first CiviCRM-system in combination with Wordpress. My client currently uses CiviCRM in combination with Drupal, so I migrated the CiviCRM-database. The system mainly focusses on CiviEvents.
  The below is tested while not logged in as a Wordpress-user.</p>
  
  <p><strong>The problem</strong></p>
  
  <p>The problem I’m facing is that when I want to subscribe on a CiviEvent with the standard register-form provided by Civi, I end up getting redirected to this URL and this error is presented:</p>
  
  <hr>
  
  <p>Redirected to:</p>
  
  <pre><code>http://localhost/DNN/?page=CiviCRM&amp;q=civicrm%2Fevent%2Fregister&amp;_qf_ThankYou_display=true&amp;qfKey=74c1a421f35974b95728fb7b661a9d79_1904
  </code></pre>
  
  <hr>
  
  <p>Presented error: Could not find valid value for id</p>
  
  <p><a href="https://i.sstatic.net/QpM9s.png" rel="noreferrer"><img src="https://i.sstatic.net/QpM9s.png" alt="enter image description here"></a></p>
  
  <hr>
  
  <p>The registration does come through though. So apparently, saving the registration is going well.</p>
  
  <p>When I debugged this issue I found that this error is thrown when the class <strong>CRM_Event_StateMachine_Registration</strong>  is instantiated and the following is executed:</p>
  
  <pre><code>$id = CRM_Utils_Request::retrieve('id', 'Positive', $controller, TRUE);
  </code></pre>
  
  <p><em>(file: CRM/Event/StateMachine/Registration.php)</em></p>
  
  <p>The method <strong>retrieve</strong> tries to extract the value for <strong>id</strong> from either $_GET, $_POST or $_REQUEST. In this case, he tries to extract it from $_REQUEST. The contents of $_REQUEST is:</p>
  
  <pre><code>Array
  (
      [page] =&gt; CiviCRM
      [q] =&gt; civicrm/event/register
      [page_id] =&gt; 6
      [noheader] =&gt; 1
      [qfKey] =&gt; ecb991dac9477d393014910b1472fb2b_9259
      [entryURL] =&gt; http://localhost/DNN/?page=CiviCRM&amp;q=civicrm/event/register&amp;page_id=6&amp;page=CiviCRM&amp;id=506&amp;reset=1
      [scriptFee] =&gt; 
      [scriptArray] =&gt; 
      [_qf_default] =&gt; Register:upload
      [MAX_FILE_SIZE] =&gt; 33554432
      [phone-Primary-2] =&gt; 0612345678
      [current_employer] =&gt; Test-employer
      [first_name] =&gt; Test-firstname
      [last_name] =&gt; Test-lastname
      [street_address-2] =&gt; Test-street-address
      [postal_code-2] =&gt; Test-postal-code
      [city-2] =&gt; Test-city
      [participant_source] =&gt; 
      [email-Primary] =&gt; test@test.com
  )
  </code></pre>
  
  <p>As you can see, <strong>id</strong> is indeed missing. So I think the real question is: why isn’t Civi sending the id in this request? It is a standard, by Civi provided functionality after all.</p>
  
  <p>Does anyone have any idea why I’m getting this message?</p>
  
  <p>For completeness, this the backtrace from the point this error is thrown:</p>
  
  <pre><code>0 - Request.php - Line: 95 - dnn_backtrace () - /DNN/wp-content/plugins/civicrm/civicrm/CRM/Utils/Request.php
  1 - Registration.php - Line: 52 - retrieve () - /DNN/wp-content/plugins/civicrm/civicrm/CRM/Event/StateMachine/Registration.php
  2 - Registration.php - Line: 47 - __construct () - /DNN/wp-content/plugins/civicrm/civicrm/CRM/Event/Controller/Registration.php
  3 - Invoke.php - Line: 307 - __construct () - /DNN/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php
  4 - Invoke.php - Line: 86 - runItem () - /DNN/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php
  5 - Invoke.php - Line: 54 - _invoke () - /DNN/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php
  6 - civicrm.php - Line: 1189 - invoke () - /DNN/wp-content/plugins/civicrm/civicrm.php
  7 - civicrm.basepage.php - Line: 134 - invoke () - /DNN/wp-content/plugins/civicrm/includes/civicrm.basepage.php
  8 - - Line: - basepage_handler () - 
  9 - plugin.php - Line: 571 - call_user_func_array () - /DNN/wp-includes/plugin.php
  10 - class-wp.php - Line: 622 - do_action_ref_array () - /DNN/wp-includes/class-wp.php
  11 - functions.php - Line: 877 - main () - /DNN/wp-includes/functions.php
  12 - wp-blog-header.php - Line: 14 - wp () - /DNN/wp-blog-header.php
  13 - index.php - Line: 19 - require () - /DNN/index.php
  </code></pre>
  
  <hr>
  
  <h2>EDIT</h2>
  
  <p>I forgot all about the error-logging Civi does. This is the error that is logged after registration.</p>
  
  <pre><code>Aug 18 14:31:54  [info] $Fatal Error Details = Array
  (
      [message] =&gt; Could not find valid value for id
      [code] =&gt; 
  )
  
  
  Aug 18 14:31:54  [info] $backTrace = #0 /DNN/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php(363): CRM_Core_Error::backtrace("backTrace", TRUE)
  #1 /DNN/wp-content/plugins/civicrm/civicrm/CRM/Utils/Request.php(96): CRM_Core_Error::fatal("Could not find valid value for id")
  #2 /DNN/wp-content/plugins/civicrm/civicrm/CRM/Event/StateMachine/Registration.php(52): CRM_Utils_Request::retrieve("id", "Positive", Object(CRM_Event_Controller_Registration), TRUE)
  #3 /DNN/wp-content/plugins/civicrm/civicrm/CRM/Event/Controller/Registration.php(47): CRM_Event_StateMachine_Registration-&gt;__construct(Object(CRM_Event_Controller_Registration), TRUE)
  #4 /DNN/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(307): CRM_Event_Controller_Registration-&gt;__construct("Event Registration", TRUE, "null", NULL, "false")
  #5 /DNN/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(86): CRM_Core_Invoke::runItem((Array:15))
  #6 /DNN/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(54): CRM_Core_Invoke::_invoke((Array:3))
  #7 /DNN/wp-content/plugins/civicrm/civicrm.php(1189): CRM_Core_Invoke::invoke((Array:3))
  #8 /DNN/wp-content/plugins/civicrm/includes/civicrm.basepage.php(134): CiviCRM_For_WordPress-&gt;invoke()
  #9 [internal function](): CiviCRM_For_WordPress_Basepage-&gt;basepage_handler(Object(WP))
  #10 /DNN/wp-includes/plugin.php(571): call_user_func_array((Array:2), (Array:1))
  #11 /DNN/wp-includes/class-wp.php(622): do_action_ref_array("wp", (Array:1))
  #12 /DNN/wp-includes/functions.php(877): WP-&gt;main("")
  #13 /DNN/wp-blog-header.php(14): wp()
  #14 /DNN/index.php(19): require("/DNN/wp-blog-header.php")
  #15 {main}
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-18T23:59:55.937Z
Comments.Text: What's your exact version? I had a client contact me today with the exact same symptoms when trying to register for a new event. They're on Civi 4.6.0 with Wordpress 4.2.4.
Comments.UserDisplayName: Nicholai
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-19T09:27:36.290Z
Comments.Text: I'm using Civi 4.6.4 with Wordpress 4.2.2
Comments.UserDisplayName: user825
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-19T12:46:41.400Z
Comments.Text: Is this a free or paid event? Perhaps we can narrow it down to a payment processor (or lack thereof)?
Comments.UserDisplayName: Nicholai
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-09-02T05:39:18.710Z
Comments.Text: Have the same issue on Drupal 7 with Civi 4.6.8
  Can't seem to figure this out.
  This is a paid event using a price set
Comments.UserDisplayName: Yossi
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-09-10T18:06:58.580Z
Comments.Text: I'm also having similar issues ever since I moved up to 4.6.8. Getting errors on Contribution and event forms. All errors point to Base-Url issues. Didn't have any errors prior to upgrade from 4.6.7.
  My base url is set to https://www.mysite.com in settings.php and in civicrm.settings.php i have this :
  define( 'CIVICRM_UF_BASEURL', $base_url . '/');
Comments.UserDisplayName: Yossi
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-22T10:23:08.793Z
Comments.Text: I'm having the same issue (WP4.4.1, Civi4.6.10, Stripe ext 1.9.1). The extension resource url is set, and the WP Base Page using the default civicrm (which is there with the 'Do not delete this page' warning). Still getting the "Could not find valid value for ID" error. Since I'm emailing confirmation of registration, is there a way to disable the final thankyou page / redirect so that folks don't see the spurious error? I'm taking payments so it's causing more than the usual consternation.
Comments.UserDisplayName: John Bradford
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-22T10:52:52.587Z
Comments.Text: Hi @John, thanks for your post but this doesn't appear to answer the original question.  It would be better posted as a new question (perhaps with a reference to this question).  You would be more likely to get a response that way.
Comments.UserDisplayName: William Mortada
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-23T03:21:44.647Z
Comments.Text: If you have a new question, please ask it by clicking the [Ask Question](http://civicrm.stackexchange.com/questions/ask) button. Include a link to this question if it helps provide context. - [From Review](/review/low-quality-posts/2948)
Comments.UserDisplayName: Chris Burgess
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-09-08T18:15:43.860Z
Comments.Text: Hi - just fyi, $id is indeed not stored in the $REQUEST as per your debugging, but IS stored in the session ($controller)
Comments.UserDisplayName: Lesley Evensen
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-29T14:54:40.273Z
Comments.Text: I have an identical problem when I link the event in a page in wordpress (4.7.1 with Civicrm 4.7.15): http://www.grag.org/corso-base-astronomia-pratica-santa-marinella/?page=CiviCRM&q=civicrm%2Fevent%2Fregister&id=22&reset=1
  doesn't work
  (corso-base-astronomia-pratica-santa-marinella is the title of the article on wordpress) http://www.grag.org/civicrm/?page=CiviCRM&q=civicrm/event/register&p=4021&id=22&reset=1
  works I don't how to manage this problem.
  I check the base url and it is correct.
Comments.UserDisplayName: pk825
Tags: <civievent><wordpress><registration>
Title: CiviEvent - Error when registering: Could not find valid value for id
ThreadText: # CiviEvent - Error when registering: Could not find valid value for id
  
  (Asked by: username_0 on 2015-08-18)
  
  This is my first question on a stackexchange-like website, so bare with if I fail to mention something important about my question.
  
  **The situation**
  
  At the moment, I’m working on my very first CiviCRM-system in combination with Wordpress. My client currently uses CiviCRM in combination with Drupal, so I migrated the CiviCRM-database. The system mainly focusses on CiviEvents.
  The below is tested while not logged in as a Wordpress-user.
  
  **The problem**
  
  The problem I’m facing is that when I want to subscribe on a CiviEvent with the standard register-form provided by Civi, I end up getting redirected to this URL and this error is presented:
  
  ---
  
  Redirected to:
  
  ```
  http://localhost/DNN/?page=CiviCRM&q=civicrm%2Fevent%2Fregister&_qf_ThankYou_display=true&qfKey=74c1a421f35974b95728fb7b661a9d79_1904
  
  ```
  
  ---
  
  Presented error: Could not find valid value for id
  
  [![enter image description here](https://i.sstatic.net/QpM9s.png)](https://i.sstatic.net/QpM9s.png)
  
  ---
  
  The registration does come through though. So apparently, saving the registration is going well.
  
  When I debugged this issue I found that this error is thrown when the class **CRM\_Event\_StateMachine\_Registration** is instantiated and the following is executed:
  
  ```
  $id = CRM_Utils_Request::retrieve('id', 'Positive', $controller, TRUE);
  
  ```
  
  *(file: CRM/Event/StateMachine/Registration.php)*
  
  The method **retrieve** tries to extract the value for **id** from either $\_GET, $\_POST or $\_REQUEST. In this case, he tries to extract it from $\_REQUEST. The contents of $\_REQUEST is:
  
  ```
  Array
  (
      [page] => CiviCRM
      [q] => civicrm/event/register
      [page_id] => 6
      [noheader] => 1
      [qfKey] => ecb991dac9477d393014910b1472fb2b_9259
      [entryURL] => http://localhost/DNN/?page=CiviCRM&q=civicrm/event/register&page_id=6&page=CiviCRM&id=506&reset=1
      [scriptFee] => 
      [scriptArray] => 
      [_qf_default] => Register:upload
      [MAX_FILE_SIZE] => 33554432
      [phone-Primary-2] => 0612345678
      [current_employer] => Test-employer
      [first_name] => Test-firstname
      [last_name] => Test-lastname
      [street_address-2] => Test-street-address
      [postal_code-2] => Test-postal-code
      [city-2] => Test-city
      [participant_source] => 
      [email-Primary] => test@test.com
  )
  
  ```
  
  As you can see, **id** is indeed missing. So I think the real question is: why isn’t Civi sending the id in this request? It is a standard, by Civi provided functionality after all.
  
  Does anyone have any idea why I’m getting this message?
  
  For completeness, this the backtrace from the point this error is thrown:
  
  ```
  0 - Request.php - Line: 95 - dnn_backtrace () - /DNN/wp-content/plugins/civicrm/civicrm/CRM/Utils/Request.php
  1 - Registration.php - Line: 52 - retrieve () - /DNN/wp-content/plugins/civicrm/civicrm/CRM/Event/StateMachine/Registration.php
  2 - Registration.php - Line: 47 - __construct () - /DNN/wp-content/plugins/civicrm/civicrm/CRM/Event/Controller/Registration.php
  3 - Invoke.php - Line: 307 - __construct () - /DNN/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php
  4 - Invoke.php - Line: 86 - runItem () - /DNN/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php
  5 - Invoke.php - Line: 54 - _invoke () - /DNN/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php
  6 - civicrm.php - Line: 1189 - invoke () - /DNN/wp-content/plugins/civicrm/civicrm.php
  7 - civicrm.basepage.php - Line: 134 - invoke () - /DNN/wp-content/plugins/civicrm/includes/civicrm.basepage.php
  8 - - Line: - basepage_handler () - 
  9 - plugin.php - Line: 571 - call_user_func_array () - /DNN/wp-includes/plugin.php
  10 - class-wp.php - Line: 622 - do_action_ref_array () - /DNN/wp-includes/class-wp.php
  11 - functions.php - Line: 877 - main () - /DNN/wp-includes/functions.php
  12 - wp-blog-header.php - Line: 14 - wp () - /DNN/wp-blog-header.php
  13 - index.php - Line: 19 - require () - /DNN/index.php
  
  ```
  
  ---
  
  ## EDIT
  
  I forgot all about the error-logging Civi does. This is the error that is logged after registration.
  
  ```
  Aug 18 14:31:54  [info] $Fatal Error Details = Array
  (
      [message] => Could not find valid value for id
      [code] => 
  )
  
  Aug 18 14:31:54  [info] $backTrace = #0 /DNN/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php(363): CRM_Core_Error::backtrace("backTrace", TRUE)
  #1 /DNN/wp-content/plugins/civicrm/civicrm/CRM/Utils/Request.php(96): CRM_Core_Error::fatal("Could not find valid value for id")
  #2 /DNN/wp-content/plugins/civicrm/civicrm/CRM/Event/StateMachine/Registration.php(52): CRM_Utils_Request::retrieve("id", "Positive", Object(CRM_Event_Controller_Registration), TRUE)
  #3 /DNN/wp-content/plugins/civicrm/civicrm/CRM/Event/Controller/Registration.php(47): CRM_Event_StateMachine_Registration->__construct(Object(CRM_Event_Controller_Registration), TRUE)
  #4 /DNN/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(307): CRM_Event_Controller_Registration->__construct("Event Registration", TRUE, "null", NULL, "false")
  #5 /DNN/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(86): CRM_Core_Invoke::runItem((Array:15))
  #6 /DNN/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(54): CRM_Core_Invoke::_invoke((Array:3))
  #7 /DNN/wp-content/plugins/civicrm/civicrm.php(1189): CRM_Core_Invoke::invoke((Array:3))
  #8 /DNN/wp-content/plugins/civicrm/includes/civicrm.basepage.php(134): CiviCRM_For_WordPress->invoke()
  #9 [internal function](): CiviCRM_For_WordPress_Basepage->basepage_handler(Object(WP))
  #10 /DNN/wp-includes/plugin.php(571): call_user_func_array((Array:2), (Array:1))
  #11 /DNN/wp-includes/class-wp.php(622): do_action_ref_array("wp", (Array:1))
  #12 /DNN/wp-includes/functions.php(877): WP->main("")
  #13 /DNN/wp-blog-header.php(14): wp()
  #14 /DNN/index.php(19): require("/DNN/wp-blog-header.php")
  #15 {main}
  
  ```
  
  **Tags:** civievent, wordpress, registration
  
  > **Comments:**
  > **username_1**: What's your exact version? I had a client contact me today with the exact same symptoms when trying to register for a new event. They're on Civi 4.6.0 with Wordpress 4.2.4.  
  > **username_0**: I'm using Civi 4.6.4 with Wordpress 4.2.2  
  > **username_1**: Is this a free or paid event? Perhaps we can narrow it down to a payment processor (or lack thereof)?  
  > **username_2**: Have the same issue on Drupal 7 with Civi 4.6.8 Can't seem to figure this out. This is a paid event using a price set  
  > **username_2**: I'm also having similar issues ever since I moved up to 4.6.8. Getting errors on Contribution and event forms. All errors point to Base-Url issues. Didn't have any errors prior to upgrade from 4.6.7. My base url is set to https://www.mysite.com in settings.php and in civicrm.settings.php i have this : define( 'CIVICRM_UF_BASEURL', $base_url . '/');  
  > **username_3**: I'm having the same issue (WP4.4.1, Civi4.6.10, Stripe ext 1.9.1). The extension resource url is set, and the WP Base Page using the default civicrm (which is there with the 'Do not delete this page' warning). Still getting the "Could not find valid value for ID" error. Since I'm emailing confirmation of registration, is there a way to disable the final thankyou page / redirect so that folks don't see the spurious error? I'm taking payments so it's causing more than the usual consternation.  
  > **username_4**: Hi @username_3, thanks for your post but this doesn't appear to answer the original question.  It would be better posted as a new question (perhaps with a reference to this question).  You would be more likely to get a response that way.  
  > **username_5**: If you have a new question, please ask it by clicking the [Ask Question](http://civicrm.stackexchange.com/questions/ask) button. Include a link to this question if it helps provide context. - [From Review](/review/low-quality-posts/2948)  
  > **username_6**: Hi - just fyi, $id is indeed not stored in the $REQUEST as per your debugging, but IS stored in the session ($controller)  
  > **username_7**: I have an identical problem when I link the event in a page in wordpress (4.7.1 with Civicrm 4.7.15): http://www.grag.org/corso-base-astronomia-pratica-santa-marinella/?page=CiviCRM&q=civicrm%2Fevent%2Fregister&id=22&reset=1 doesn't work (corso-base-astronomia-pratica-santa-marinella is the title of the article on wordpress) http://www.grag.org/civicrm/?page=CiviCRM&q=civicrm/event/register&p=4021&id=22&reset=1 works I don't how to manage this problem. I check the base url and it is correct.  
  
  ---
  
  ## 7 answers
  
  ### Answer by username_10 on 2015-09-21. Score: 11 | Accepted answer
  
  This is a bit of "surprise" but essentially for 4.6 and beyond Civi event registration for Wordpress won't work unless you either 1) use a 'base page' or a 2) WP short code
  
  Solution #1 has two steps.
  
  1. create a WP page with the 'civicrm' permalink
  2. set a 'base page' within CiviCRM
  
  See attached images.
  
  [![new page](https://i.sstatic.net/Glz22.png)](https://i.sstatic.net/Glz22.png)
  
  [![base page](https://i.sstatic.net/Lc8Gx.png)](https://i.sstatic.net/Lc8Gx.png)
  
  > **Comments:**
  > **username_0**: Thanks for your answer! Just checked and apparently I don't have a base page set. So will definitely try that, but at this point I already downgraded to Civi 4.4.19 (LTS), since on this version the registration works. I'm hoping to upgrade somewhere in the near future. Thanks!  
  > **username_0**: We finally made time to test this answer (since we were upgrading Civi) and it works! It is worth mentioning though that my initial question was about Civi 4.6.4 and I tested this answer when I was already updated to 4.7.6.  
  
  ---
  
  ### Answer by username_8 on 2022-01-03. Score: 7
  
  I stumbled on this issue on CiviCRM 5.44 sites on WordPress, and the issue was that the site did not have "Clean URLs" enabled, since it was using an old civicrm.settings.php.
  
  Make sure that the civicrm.settings.php has this bit of code:
  
  ```
    if (!defined('CIVICRM_CLEANURL')) {
      if ( function_exists('variable_get') && variable_get('clean_url', '0') != '0') {
        define('CIVICRM_CLEANURL', 1 );
      }
      elseif ( function_exists('config_get') && config_get('system.core', 'clean_url') != 0) {
        define('CIVICRM_CLEANURL', 1 );
      }
      elseif( function_exists('get_option') && get_option('permalink_structure') != '' ) {
        define('CIVICRM_CLEANURL', 1 );
      }
      else {
        define('CIVICRM_CLEANURL', 0);
      }
    }
  
  ```
  
  and then in WordPress permalink settings, make sure that it uses the "post name" to form permalinks (this might not be strictly necessary according to docs, but I found that it helps), and save the permalinks setting form, so that the permalink cache is flushed.
  
  Finally, Event Registration pages will be accessible using URLs that look like:
  
  <https://example.org/civicrm/event/register/?id=123&reset=1>
  
  
  ---
  
  ### Answer by username_9 on 2015-09-08. Score: 3
  
  I was having a similar problem. I noticed the base url for WordPress was not set.
  
  If you haven't set that, try setting that in **Administer > CMS Database Integration** and let us know if that fixed your issue.
  
  Make sure the event is not the home page, that seems to cause problems with the base url.
  
  > **Comments:**
  > **username_10**: It's called a "base page" actually.  And the second step of this configuration is to actually create a WP page with this URL.  For instance if your base page is "civi" your WP page must have the permalink of "civi" as well.  See my post below for screenshots  
  > **username_0**: I misunderstood your answer, username_9 username_9. I noticed it was set to the base URL of the website, so I thought that was okay. username_10 cleared this up now and will try this solution! Thanks for your help!  
  
  ---
  
  ### Answer by username_11 on 2016-07-27. Score: 1
  
  On 4.7.9 + WP 4.5.3 I had this problem.
  
  I have a paid event, with PayPal as payment processor, but also the Pay Later option is enabled.
  
  Registrations proceed fine when paid with PayPal. I only get this error when a user ticks the Pay Later option.
  
  I tried using a WP shortcode as username_10 mentioned but that did not work. I *had* to set a Base Page - i.e., Administer | System Settings | CMS Database Integration could not be blank.
  
  It doesn't have to be civicrm, it can be anything you want. You can use <http://www.domain.org/event> or something similar.
  
  Then you have to create a Page in WordPress with this URL as the permalink. I then put the event shortcode on this page and it works great!
  
  In my case I then set up an intro page at <http://www.domain.org/> with a "Registration" link to <http://www.domain.org/event>.
  
  
  ---
  
  ### Answer by username_6 on 2017-08-10. Score: 1
  
  If you upgrade from CiviCRM < 4.6, and have a WP frontend with links to Civicrm pages (e.g. an event calendar) that are full URLs, you'll need to edit those links: from '<http://example.com/?page=Civicrm>...' to '<http://example.com/civicrm/?page=Civicrm>...' to get the basepage.
  
  
  ---
  
  ### Answer by username_12 on 2021-10-13. Score: 1
  
  I had this problem intermittently for some time when embedding event registration forms using a Wordpress shortcode. It has to do with page caching. CiviCRM parses the shortcode to capture the event ID and adds the id value to the global $\_GET object. If the page is loaded from cache (usually when the back/forward button is pressed) the code that parses the shortcode does not run, and the event ID is not added to $\_GET.
  
  I was able to fix this issue by making a page cache exception with the caching plugin I'm using.
  
  I think this behavior is essentially a bug and CiviCRM should output a hidden form variable with the event ID so that it still gets passed to the "Thank You" page if the registration form is loaded from cache.
  
  This is where Civi parses the shortcode and assigns the environment vars:
  civicrm/includes/civicrm.shortcode.php:
  
  ```
  // Preprocess shortcode attributes.
  $args = $this->preprocess_atts($atts);
  
  // Sanity check for improperly constructed shortcode.
  if ($args === FALSE) {
    return '<p>' . __('Do not know how to handle this shortcode.', 'civicrm') . '</p>';
  }
  
  // invoke() requires environment variables to be set.
  foreach ($args as $key => $value) {
    if ($value !== NULL) {
      set_query_var($key, $value);
      $_REQUEST[$key] = $_GET[$key] = $value;
    }
  }
  
  ```
  
  Here are 3 solutions that are verified working:
  
  **1) Use the "civicrm\_buildForm" hook with a template Region to add a custom template to Event Registration and Contribution forms (recommended).**
  
  ```
  add_action( 'civicrm_buildForm', 'onBeforeFormBuilt' );
  
  function onBeforeFormBuilt($formName) {
      $formSubmitMap = array(
          'CRM_Contribute_Form_Contribution_Main' => array('contribution-main-not-you-block', 'CRM/Custom/ContributionFormId.tpl'),
          'CRM_Event_Form_Registration_Register' => array('event-register-not-you-block', 'CRM/Custom/EventFormId.tpl')
      );
      
      if ( in_array($formName, array_keys($formSubmitMap)) ) {
          $formType = $formSubmitMap[$formName];
      
          CRM_Core_Region::instance($formType[0])->add(array(
              'template' => $formType[1],
          ));
      }
  }
  
  ```
  
  Contents of ContributionFormId.tpl:
  
  ```
  <input type="hidden" name="id" value="{$contributionPageID}">
  
  ```
  
  Contents of EventFormId.tpl:
  
  ```
  <input type="hidden" name="id" value="{$event.id}">
  
  ```
  
  **2) Modify core code (not recommended).**
  
  If you want to allow your registration page to be cached and you're willing to modify Core code, here is a quick hack:
  civicrm/CRM/Core/Form.php (after qfKey section):
  
  ```
  if (isset($_REQUEST['id'])) {
      $this->addElement('hidden', 'id', $_REQUEST['id']); }
  }
  
  ```
  
  **3) Use Javascript to perform a hard reload when the page is loaded from cache (not recommended).**
  
  ```
  function purgeCache() {
      if ( function_exists('has_tag') && function_exists('get_the_id') && has_tag('logged-in-no-cache', get_the_id()) ) {
          // If this page has a tag "no-cache", force browser to NOT load from cache
          $currQs = parsedUrl()['query'];
  
          echo "
          <script>
              // Back buttom was pressed prior to loading this page
              if (window.performance) {
                  if (window.performance.navigation.type === 2) {
                      location.reload(true);
                  }
              // Use History to force cache purge
              } else if (window.history && history.pushState) {
                  history.pushState('page-load', '', '" . (!empty($currQs) ? $currQs . '&' : '?') . "w3tc_flush_post&post_id=" . get_the_id() . "');
              }
          </script>";
      }
  }
  
  ```
  
  I haven't verified the history.pushState approach, but it should work OK.
  
  
  ---
  
  ### Answer by username_1 on 2015-08-19. Score: 0
  
  I'm not sure of the cause, but I have a workaround. I'm guessing that you are using the direct link that Civi tells you to copy and paste from the event management page. Using that gives me the error too. However I created a WP page, embedded the event registration as a shortcode, and made it through registration and confirmation without errors.
  
  > **Comments:**
  > **username_0**: But when you embed the registration form with  a shortcode, you have to specify the event to show the form for, right?  To give a little more insight, I created a custom shortcode that lists CiviEvents. When you click on one of these events, you'll go to the event detailpage, which is the default page from Civi that I overwrite in the custom templates folder. On this page I use the URL to the registration page that is also used in the default page from Civi.  
  
  ---
  
  