Answers.Body: <p>I can't add a comment (doh, stupid reputation requirement) so I'm answering when Thomas Jaunism wrote: "Why would CiviCRM be trying to load the page.php and not the front-page.php that the form is on?"</p>
  
  <p>The Civi plugin loads the WordPress theme's page.php template because many (if not most) themes define a homepage template which does not contain <code>the_content()</code> but rather collections of widgets and archive views. Loading page.php has proved to be the most reliable way to show Civi content on the front end.</p>
  
  <p>If you want Civi to load a different template, there is a filter for this called <code>civicrm_basepage_template</code>. You can therefore load a different template with code such as the following in your functions.php file:</p>
  
  <pre><code>add_filter( 'civicrm_basepage_template', 'use_my_own_template_for_civi' );
  function use_my_own_template_for_civi( $template ) {
      if ( some condition is met ) {
          return 'your-template-name.php';
      }
      return $template;
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-18T21:50:28.227Z
Answers.Text: Thanks. I've tried to change the template but civicrm seems to strip the css from it when it loads with the validation errors. It also replaces 'the_content();' of every page with the form and its validation errors (in printable format).
Answers.UserDisplayName: thomas jaunism
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-19T12:27:17.850Z
Answers.Text: If you've got PHP errors (and you have) then you'll need to solve those first before you can address CSS or Javascript issues, as Chris Burgess suggests.
Answers.UserDisplayName: Christian Wach
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-19T12:56:30.730Z
Answers.Text: Cheers. I'm still trying to solve those errors. But have hit a bit of wall. Tried reinstalling a new version but there were other errors so am running with this as it has a reasonable amount of functionality.
Answers.UserDisplayName: thomas jaunism
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-01T09:34:20.313Z
Answers.Text: Just to be explicit, for not-so-techies like me, the WordPress theme is not implementing 'page.php' (Just as Christian Wach has explained). Our theme uses 'templates/front-page.php' So we simply need to add the code snippet above to the bottom of your theme's "functions.php" file. The "_some condition is met_" can be as follows: `add_filter( 'civicrm_basepage_template', 'use_my_own_template_for_civi' );
  function use_my_own_template_for_civi( $template ) {
      if ( $template=='page.php' ) {
          return 'templates/front-page.php';
      }
      return $template;
  }`
Answers.UserDisplayName: Darren
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-03-02T09:49:42.947Z
Answers.Text: Darren, there's new template logic in the pipeline. Please have a look at https://github.com/civicrm/civicrm-wordpress/pull/96 which is less aggressive in its substitution. It will leave the assigned template alone (although this still filterable as per your code) unless it's the homepage, in which case it will try and load 'page.php'. There's a new filter to override this.
Answers.UserDisplayName: Christian Wach
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-18T13:12:42.037Z
Answers.LastActivityDate: 2015-05-20T09:12:19.553Z
Answers.LastEditDate: 2015-05-20T09:12:19.553Z
Answers.UserDisplayName: Christian Wach
Answers.Body: <p>Viewing the PHP error log revealed a PHP parse error -</p>
  
  <pre><code>[12-May-2015 04:20:05 UTC] PHP Parse error:
    syntax error, unexpected end of file, expecting function (T_FUNCTION) in
    /path/to/CRM/Profile/Form/Edit.php on line 346
  </code></pre>
  
  <p>We checked that the file in question Edit.php validated, which suggests that perhaps there is a mismatched bracket somewhere else in the site codebase (eg theme files or another plugin).</p>
  
  <p>Recommend -</p>
  
  <ul>
  <li>validating files which have been recently modified (<code>php -l *.php</code>)</li>
  <li>restoring a known good copy of the CiviCRM codebase</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-12T22:35:19.047Z
Answers.Text: In fact is has to do with my page.php in the theme directory. Other themes work OK. If I delete the page.php from theme directory it works fine. Why would civiCRM be trying to load the page.php and not the front-page.php that the form is on?
Answers.UserDisplayName: thomas jaunism
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-12T22:45:35.783Z
Answers.Text: I'm guessing that's because `/?page=CiviCRM` to WordPress means you're no longer on the front page when you've submitted the form. You'll need your page template to be valid anyway or the whole site is broken. You can check your PHP is valid using `php -l`, and you can compare your current template against previous versions and/or the template you based it on to see what's changed (use a file compare tool in your text editor, or `diff` etc).
Answers.UserDisplayName: Chris Burgess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-13T00:18:47.387Z
Answers.Text: Thanks. Page template works fine throughout the site. The only thing that's changed is civiCRM update to 4.6 and shift to server...
Answers.UserDisplayName: thomas jaunism
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-13T00:23:16.030Z
Answers.Text: Your [PHP error_log](http://logisticsworkersnetwork.org/error_log) still indicates that you have a misconfigured or incomplete CiviCRM codebase - can't find class [CRM_Profile_Page_Router](https://github.com/civicrm/civicrm-core/blob/master/CRM/Profile/Page/Router.php), require_once([CRM/Profile/Form/Edit.php](https://github.com/civicrm/civicrm-core/blob/master/CRM/Profile/Form/Edit.php)) fails etc. Verify your codebase and [follow the upgrade instructions](http://wiki.civicrm.org/confluence/display/CRMDOC/Upgrading+CiviCRM+for+WordPress).
Answers.UserDisplayName: Chris Burgess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-12T09:11:18.157Z
Answers.LastActivityDate: 2015-05-12T09:18:31.723Z
Answers.LastEditDate: 2015-05-12T09:18:31.723Z
Answers.UserDisplayName: Chris Burgess
Body: <p>I have a wordpress site <a href="http://logisticsworkersnetwork.org/" rel="nofollow">http://logisticsworkersnetwork.org/</a></p>
  
  <p>There is a 'profile' sign-up form on the front page. The sign-up form works fine but there is no CSS or theme html when someone makes a mistake on the form. It goes to this page: <a href="http://logisticsworkersnetwork.org/?page=CiviCRM&amp;q=civicrm/profile/create&amp;page_id=2" rel="nofollow">http://logisticsworkersnetwork.org/?page=CiviCRM&amp;q=civicrm/profile/create&amp;page_id=2</a> and just shows the error and the form in pure html. That is, it shows the PRINTER-FRIENDLY version of the page. The console error says: </p>
  
  <p>Uncaught ReferenceError: CRM is not defined  (anonymous function)   @   ?page=CiviCRM&amp;q=civicrm/profile/create&amp;page_id=2:100</p>
  
  <p>NB: I have removed the civiCRM CSS file with Jquery. I also have a few hidden fields which are shown when a validation error occurs. This problem only arose after I switched from my localhost environment to my server (bluehost). I upgraded to civiCRM 4.6.2 (from 4.5.8) when I uploaded the site too.</p>
  
  <p>UPDATE (12/May/2015): 
  I have tried deleting the 'templates_c' folder but it doesn't work. I have tried clearing the cache. </p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-07T10:38:18.100Z
Comments.Text: Hi, not sure I follow: if you removed the css, it's expected that the form isn't styled anymore, isn't it?
Comments.UserDisplayName: Xavier
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-07T19:44:52.843Z
Comments.Text: I just removed the default civiCRM stylesheet. I've added my own styling for the form and validation errors. The  problem is that everything (CSS, JS, page elements) disappears when there's a validation error. Does that make sense? If you follow the link and try and submit the form without an email address you'll see what I mean,
Comments.UserDisplayName: thomas jaunism
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-12T04:58:37.537Z
Comments.Text: @thomasjaunism to suit StackExchange format, would you consider phrasing this as a question? eg either "Why does this CiviCRM form fail validation?" or "Why does CiviCRM / Wordpress render a validation failure without the Wordpress theme?". SE format requires a question which we can answer, this is more of a descriptive report so it's hard to "answer".
Comments.UserDisplayName: Chris Burgess
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-12T07:45:18.723Z
Comments.Text: @Chris Changed to question.
Comments.UserDisplayName: thomas jaunism
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-12T08:10:55.457Z
Comments.Text: I think you'll need to debug some more to track this down. There are logfiles which show additional information. CiviCRM's logfile is in `public_html/wp-content/plugins/files/civicrm/ConfigAndLog/` on your Bluehost server, and on Bluehost the PHP error log is in your site root eg `public_html/error_log`. You can SSH in and use `tail -f path/to/file.log` to watch the logs while you reproduce the error.
Comments.UserDisplayName: Chris Burgess
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-12T08:13:46.293Z
Comments.Text: I wasn't able to reproduce this behaviour on a local WP install. Something is afoot there (it could be any of a number of things). Have you checked that your Bluehost account is set to use the [correct PHP version for CiviCRM](http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+PHP+Requirements)?
Comments.UserDisplayName: Chris Burgess
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-12T08:23:50.203Z
Comments.Text: Thanks, Yeah it's currently set to 5.4. Everything worked fine on my local install
Comments.UserDisplayName: thomas jaunism
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-12T08:50:51.043Z
Comments.Text: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/23688/discussion-between-chris-burgess-and-thomas-jaunism).
Comments.UserDisplayName: Chris Burgess
Tags: <wordpress><profile>
Title: Why does CiviCRM render a validation failure without the Wordpress theme?
ThreadText: # Why does CiviCRM render a validation failure without the Wordpress theme?
  
  (Asked by: username_0 on 2015-05-07)
  
  I have a wordpress site <http://logisticsworkersnetwork.org/>
  
  There is a 'profile' sign-up form on the front page. The sign-up form works fine but there is no CSS or theme html when someone makes a mistake on the form. It goes to this page: <http://logisticsworkersnetwork.org/?page=CiviCRM&q=civicrm/profile/create&page_id=2> and just shows the error and the form in pure html. That is, it shows the PRINTER-FRIENDLY version of the page. The console error says:
  
  Uncaught ReferenceError: CRM is not defined (anonymous function) @ ?page=CiviCRM&q=civicrm/profile/create&page\_id=2:100
  
  NB: I have removed the civiCRM CSS file with Jquery. I also have a few hidden fields which are shown when a validation error occurs. This problem only arose after I switched from my localhost environment to my server (bluehost). I upgraded to civiCRM 4.6.2 (from 4.5.8) when I uploaded the site too.
  
  UPDATE (12/May/2015):
  I have tried deleting the 'templates\_c' folder but it doesn't work. I have tried clearing the cache.
  
  **Tags:** wordpress, profile
  
  > **Comments:**
  > **username_1**: Hi, not sure I follow: if you removed the css, it's expected that the form isn't styled anymore, isn't it?  
  > **username_0**: I just removed the default civiCRM stylesheet. I've added my own styling for the form and validation errors. The  problem is that everything (CSS, JS, page elements) disappears when there's a validation error. Does that make sense? If you follow the link and try and submit the form without an email address you'll see what I mean,  
  > **username_2**: @username_0 to suit StackExchange format, would you consider phrasing this as a question? eg either "Why does this CiviCRM form fail validation?" or "Why does CiviCRM / Wordpress render a validation failure without the Wordpress theme?". SE format requires a question which we can answer, this is more of a descriptive report so it's hard to "answer".  
  > **username_0**: @username_2 Changed to question.  
  > **username_2**: I think you'll need to debug some more to track this down. There are logfiles which show additional information. CiviCRM's logfile is in `public_html/wp-content/plugins/files/civicrm/ConfigAndLog/` on your Bluehost server, and on Bluehost the PHP error log is in your site root eg `public_html/error_log`. You can SSH in and use `tail -f path/to/file.log` to watch the logs while you reproduce the error.  
  > **username_2**: I wasn't able to reproduce this behaviour on a local WP install. Something is afoot there (it could be any of a number of things). Have you checked that your Bluehost account is set to use the [correct PHP version for CiviCRM](http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+PHP+Requirements)?  
  > **username_0**: Thanks, Yeah it's currently set to 5.4. Everything worked fine on my local install  
  > **username_2**: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/23688/discussion-between-username_2-username_2-and-username_0).  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2015-05-18. Score: 5
  
  I can't add a comment (doh, stupid reputation requirement) so I'm answering when username_0 username_0 wrote: "Why would CiviCRM be trying to load the page.php and not the front-page.php that the form is on?"
  
  The Civi plugin loads the WordPress theme's page.php template because many (if not most) themes define a homepage template which does not contain `the_content()` but rather collections of widgets and archive views. Loading page.php has proved to be the most reliable way to show Civi content on the front end.
  
  If you want Civi to load a different template, there is a filter for this called `civicrm_basepage_template`. You can therefore load a different template with code such as the following in your functions.php file:
  
  ```
  add_filter( 'civicrm_basepage_template', 'use_my_own_template_for_civi' );
  function use_my_own_template_for_civi( $template ) {
      if ( some condition is met ) {
          return 'your-template-name.php';
      }
      return $template;
  }
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks. I've tried to change the template but civicrm seems to strip the css from it when it loads with the validation errors. It also replaces 'the_content();' of every page with the form and its validation errors (in printable format).  
  > **username_3**: If you've got PHP errors (and you have) then you'll need to solve those first before you can address CSS or Javascript issues, as username_2 username_2 suggests.  
  > **username_0**: Cheers. I'm still trying to solve those errors. But have hit a bit of wall. Tried reinstalling a new version but there were other errors so am running with this as it has a reasonable amount of functionality.  
  > **username_4**: Just to be explicit, for not-so-techies like me, the WordPress theme is not implementing 'page.php' (Just as username_3 has explained). Our theme uses 'templates/front-page.php' So we simply need to add the code snippet above to the bottom of your theme's "functions.php" file. The "_some condition is met_" can be as follows: `add_filter( 'civicrm_basepage_template', 'use_my_own_template_for_civi' ); function use_my_own_template_for_civi( $template ) {     if ( $template=='page.php' ) {         return 'templates/front-page.php';     }     return $template; }`  
  > **username_3**: username_4, there's new template logic in the pipeline. Please have a look at https://github.com/civicrm/civicrm-wordpress/pull/96 which is less aggressive in its substitution. It will leave the assigned template alone (although this still filterable as per your code) unless it's the homepage, in which case it will try and load 'page.php'. There's a new filter to override this.  
  
  ---
  
  ### Answer by username_2 on 2015-05-12. Score: 3
  
  Viewing the PHP error log revealed a PHP parse error -
  
  ```
  [12-May-2015 04:20:05 UTC] PHP Parse error:
    syntax error, unexpected end of file, expecting function (T_FUNCTION) in
    /path/to/CRM/Profile/Form/Edit.php on line 346
  
  ```
  
  We checked that the file in question Edit.php validated, which suggests that perhaps there is a mismatched bracket somewhere else in the site codebase (eg theme files or another plugin).
  
  Recommend -
  
  * validating files which have been recently modified (`php -l *.php`)
  * restoring a known good copy of the CiviCRM codebase
  
  > **Comments:**
  > **username_0**: In fact is has to do with my page.php in the theme directory. Other themes work OK. If I delete the page.php from theme directory it works fine. Why would civiCRM be trying to load the page.php and not the front-page.php that the form is on?  
  > **username_2**: I'm guessing that's because `/?page=CiviCRM` to WordPress means you're no longer on the front page when you've submitted the form. You'll need your page template to be valid anyway or the whole site is broken. You can check your PHP is valid using `php -l`, and you can compare your current template against previous versions and/or the template you based it on to see what's changed (use a file compare tool in your text editor, or `diff` etc).  
  > **username_0**: Thanks. Page template works fine throughout the site. The only thing that's changed is civiCRM update to 4.6 and shift to server...  
  > **username_2**: Your [PHP error_log](http://logisticsworkersnetwork.org/error_log) still indicates that you have a misconfigured or incomplete CiviCRM codebase - can't find class [CRM_Profile_Page_Router](https://github.com/civicrm/civicrm-core/blob/master/CRM/Profile/Page/Router.php), require_once([CRM/Profile/Form/Edit.php](https://github.com/civicrm/civicrm-core/blob/master/CRM/Profile/Form/Edit.php)) fails etc. Verify your codebase and [follow the upgrade instructions](http://wiki.civicrm.org/confluence/display/CRMDOC/Upgrading+CiviCRM+for+WordPress).  
  
  ---
  
  