Answers.Body: <p>For the CiviContribute forms, you can choose Disable for each form from the Manage Contribution Pages screen (civicrm/admin/contribute?reset=1 on 4.6 LTS).  The Disable option is under the More link. When maintenance is done, you can Enable each one in the same way.<a href="https://i.sstatic.net/onGkc.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/onGkc.png" alt="Disable contribution forms under the More option"></a></p>
  
  <p>For something from the command line:</p>
  
  <p>There is an entity in the API called <code>ContributionPage</code> with a parameter called "Is Page Active?" (<code>is_active</code>). I just executed the <code>Create</code> action thru the API Explorer and it seems to have worked. I would test it out and see what works best for you. The API Explorer lists the drush command as: <code>drush cvapi ContributionPage.create sequential=1 id=15 is_active=0</code> (<code>0</code> being disabled and <code>1</code> being enabled)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-11T17:53:33.547Z
Answers.Text: Using the `drush cvapi ContributionPage.create sequential=1 id=15 is_active=0` command in my script is what I need! I can also do something to hide the link or change the text on disabled forms. Thank you!
Answers.UserDisplayName: Christia
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-18T00:31:28.057Z
Answers.Text: I'm thinking I'd rather not deactivate the forms. I want to find a way that preserves the page but just maybe makes the submit button turn into a box that says it's unavailabe or something.
Answers.UserDisplayName: Christia
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-17T18:44:44.007Z
Answers.Text: Yes, exactly. I'd like to be able to disable the forms in my bash scripts, probably using drush. Something like `drush vset [variable] 0`
Answers.UserDisplayName: Christia
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-17T19:50:48.160Z
Answers.Text: There is an entity in the API called ContributionPage with a parameter called "Is Page Active?" (is_active). I just executed the Create action thru the API Explorer and it seems to have worked. YMMV.  The API Explorer is listing the drush command as:
  
  drush cvapi ContributionPage.create sequential=1 id=15 is_active=0
Answers.UserDisplayName: Allen Hutchison
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-17T16:50:39.237Z
Answers.LastActivityDate: 2018-05-17T22:52:13.993Z
Answers.LastEditDate: 2018-05-17T22:52:13.993Z
Answers.UserDisplayName: Allen Hutchison
Answers.Body: <p>Maybe, we could just add an extension with a simple call to freeze the form in a buildform hook. Something like -</p>
  
  <pre><code>function example_civicrm_buildForm($formName, &amp;$form) {
    $form-&gt;freeze();
  }
  </code></pre>
  
  <p>This will display all forms in CiviCRM as read-only.</p>
  
  <p>Note: We need to enable this ext before an upgrade and disable after the process is completed.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-17T19:38:14.013Z
Answers.Text: Interesting idea!
Answers.UserDisplayName: michaelmcandrew
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-18T05:59:55.807Z
Answers.LastActivityDate: 2018-05-18T05:59:55.807Z
Answers.UserDisplayName: jitendra - fuzion
Answers.Body: <p>No there is no way of putting CiviCRM in read only or maintance mode. </p>
  
  <p>However if you put Drupal in maintaince mode only administrators could login and access civicrm. All other users cannot do anything. </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-17T16:13:58.853Z
Answers.Text: Thanks. I used to use maintenance mode but I favor having no downtime.
Answers.UserDisplayName: Christia
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-18T06:33:41.907Z
Answers.Text: We all favor no downtime, no downtime is a complex job when you are upgrading even with systems who are designed for this.
Answers.UserDisplayName: Jaap Jansma - CiviCooP
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-17T08:27:39.987Z
Answers.LastActivityDate: 2018-05-17T08:27:39.987Z
Answers.UserDisplayName: Jaap Jansma - CiviCooP
Answers.Body: <p>You could temporarily disable the CiviCRM module. That would take down all your contribution forms, etc. However you'd have to be careful to re-enable it when doing anything Civi-related in your maintenance. It must be enabled in order to upgrade CiviCRM.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-11T17:48:57.957Z
Answers.Text: This is too risky because if my update includes a CiviCRM upgrade, then the module needs to remain enabled.
Answers.UserDisplayName: Christia
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-17T16:18:55.153Z
Answers.LastActivityDate: 2018-05-17T16:18:55.153Z
Answers.UserDisplayName: Coleman
Body: <p>I have recently set up our website so that I can put it in read-only mode (using the <a href="https://www.drupal.org/project/readonlymode" rel="nofollow noreferrer">Read Only Mode module</a>) when doing maintenance, such as upgrades and code pulls, however, this is a Drupal function only and I noticed that while in read-only mode, CiviCRM front-facing forms, such as CiviContribute forms, as well as backend functions are still available. </p>
  
  <p>Is there a way to either put CiviCRM into read-only mode or turn off/deactivate the CiviContribute forms? I have written a bash script that runs all my update/upgrade processes and would like to find a way to do this using drush. For staff, I'm thinking of just deactivating the link to CiviCRM in the administrative menu, but I am most concerned with making sure users can't process transactions and write to the database during down-time. </p>
  
  <p>I'm on CiviCRM 5.1.0 and Drupal 7.59</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-05-18T05:44:03.863Z
Comments.Text: You mean that new (?) 'read only' module?
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-05-18T05:45:17.147Z
Comments.Text: how does it deal with webforms by the way? I liked the look of this but didn't go the extra step of working out how to disable all Civi forms so gave up - be good if you come up with a simple command solution
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-05-18T08:25:23.280Z
Comments.Text: Yes, I'm using the new Drupal read only mode module, I'll update my question. It seems to work great so far, by disabling all drupal forms, including the civicrm webforms module.
Comments.UserDisplayName: Christia
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-05-18T20:44:02.033Z
Comments.Text: I popped a link in
Comments.UserDisplayName: petednz - fuzion
Tags: <civicontribute><drupal><5.1.0>
Title: Is there a way to put CiviCRM in read-only mode or deactivate forms programmatically?
ThreadText: # Is there a way to put CiviCRM in read-only mode or deactivate forms programmatically?
  
  (Asked by: username_0 on 2018-05-17)
  
  I have recently set up our website so that I can put it in read-only mode (using the [Read Only Mode module](https://www.drupal.org/project/readonlymode)) when doing maintenance, such as upgrades and code pulls, however, this is a Drupal function only and I noticed that while in read-only mode, CiviCRM front-facing forms, such as CiviContribute forms, as well as backend functions are still available.
  
  Is there a way to either put CiviCRM into read-only mode or turn off/deactivate the CiviContribute forms? I have written a bash script that runs all my update/upgrade processes and would like to find a way to do this using drush. For staff, I'm thinking of just deactivating the link to CiviCRM in the administrative menu, but I am most concerned with making sure users can't process transactions and write to the database during down-time.
  
  I'm on CiviCRM 5.1.0 and Drupal 7.59
  
  **Tags:** civicontribute, drupal, 5.1.0
  
  > **Comments:**
  > **username_1**: You mean that new (?) 'read only' module?  
  > **username_1**: how does it deal with webforms by the way? I liked the look of this but didn't go the extra step of working out how to disable all Civi forms so gave up - be good if you come up with a simple command solution  
  > **username_0**: Yes, I'm using the new Drupal read only mode module, I'll update my question. It seems to work great so far, by disabling all drupal forms, including the civicrm webforms module.  
  > **username_1**: I popped a link in  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_2 on 2018-05-17. Score: 2 | Accepted answer
  
  For the CiviContribute forms, you can choose Disable for each form from the Manage Contribution Pages screen (civicrm/admin/contribute?reset=1 on 4.6 LTS). The Disable option is under the More link. When maintenance is done, you can Enable each one in the same way.[![Disable contribution forms under the More option](https://i.sstatic.net/onGkc.png)](https://i.sstatic.net/onGkc.png)
  
  For something from the command line:
  
  There is an entity in the API called `ContributionPage` with a parameter called "Is Page Active?" (`is_active`). I just executed the `Create` action thru the API Explorer and it seems to have worked. I would test it out and see what works best for you. The API Explorer lists the drush command as: `drush cvapi ContributionPage.create sequential=1 id=15 is_active=0` (`0` being disabled and `1` being enabled)
  
  > **Comments:**
  > **username_0**: Yes, exactly. I'd like to be able to disable the forms in my bash scripts, probably using drush. Something like `drush vset [variable] 0`  
  > **username_2**: There is an entity in the API called ContributionPage with a parameter called "Is Page Active?" (is_active). I just executed the Create action thru the API Explorer and it seems to have worked. YMMV.  The API Explorer is listing the drush command as:  drush cvapi ContributionPage.create sequential=1 id=15 is_active=0  
  > **username_0**: Using the `drush cvapi ContributionPage.create sequential=1 id=15 is_active=0` command in my script is what I need! I can also do something to hide the link or change the text on disabled forms. Thank you!  
  > **username_0**: I'm thinking I'd rather not deactivate the forms. I want to find a way that preserves the page but just maybe makes the submit button turn into a box that says it's unavailabe or something.  
  
  ---
  
  ### Answer by username_3 on 2018-05-18. Score: 2
  
  Maybe, we could just add an extension with a simple call to freeze the form in a buildform hook. Something like -
  
  ```
  function example_civicrm_buildForm($formName, &$form) {
    $form->freeze();
  }
  
  ```
  
  This will display all forms in CiviCRM as read-only.
  
  Note: We need to enable this ext before an upgrade and disable after the process is completed.
  
  > **Comments:**
  > **username_4**: Interesting idea!  
  
  ---
  
  ### Answer by username_5 on 2018-05-17. Score: 1
  
  No there is no way of putting CiviCRM in read only or maintance mode.
  
  However if you put Drupal in maintaince mode only administrators could login and access civicrm. All other users cannot do anything.
  
  > **Comments:**
  > **username_0**: Thanks. I used to use maintenance mode but I favor having no downtime.  
  > **username_5**: We all favor no downtime, no downtime is a complex job when you are upgrading even with systems who are designed for this.  
  
  ---
  
  ### Answer by username_6 on 2018-05-17. Score: 0
  
  You could temporarily disable the CiviCRM module. That would take down all your contribution forms, etc. However you'd have to be careful to re-enable it when doing anything Civi-related in your maintenance. It must be enabled in order to upgrade CiviCRM.
  
  > **Comments:**
  > **username_0**: This is too risky because if my update includes a CiviCRM upgrade, then the module needs to remain enabled.  
  
  ---
  
  