Answers.Body: <p>I think you need to use <a href="https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_buildAmount/" rel="nofollow noreferrer">hook_civicrm_buildAmount</a>  or <a href="https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_buildForm/" rel="nofollow noreferrer">hook_civicrm_buildForm</a> hook to change the amount on front end contribution/event pages for priceset or line items.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-02T16:21:56.853Z
Answers.Text: Thank you, you're right I needed to use buildAmount
Answers.UserDisplayName: Jeremy
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-02T16:10:58.163Z
Answers.LastActivityDate: 2020-09-02T16:10:58.163Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>On my civicrm contribution page I have a field that I want to use to calculate the membership price.</p>
  <p>Currently Im trying to use the membershipTypeValues hook to edit the price after the contribution page has been submitted</p>
  <p>Heres the code</p>
  <pre><code>add_filter('civicrm_membershipTypeValues', &quot;updatePrice&quot;, 10, 2);
  
  function updatePrice(&amp;$form, &amp;$membershipTypeValues) {
      $membershipTypeValues[14]['minimum_fee'] = &quot;40.00&quot;;
  }
  </code></pre>
  <p>Theoretically this should change the membership price to $40 but the price doesn't change on the conformation screen.</p>
  <p>The code runs and if I print out the $membershipTypeValues array I can see the minimum fee has changed to $40</p>
  <p>Any ideas on how to fix this would be great</p>
  <p>Thank you</p>
  
Tags: <civicontribute><civimember><php><hooks>
Title: membershipTypeValues hook not updating membership price
ThreadText: # membershipTypeValues hook not updating membership price
  
  (Asked by: username_0 on 2020-09-02)
  
  On my civicrm contribution page I have a field that I want to use to calculate the membership price.
  Currently Im trying to use the membershipTypeValues hook to edit the price after the contribution page has been submitted
  Heres the code
  add_filter('civicrm_membershipTypeValues', "updatePrice", 10, 2);
  
  function updatePrice(&$form, &$membershipTypeValues) {
      $membershipTypeValues[14]['minimum_fee'] = "40.00";
  }
  
  Theoretically this should change the membership price to $40 but the price doesn't change on the conformation screen.
  The code runs and if I print out the $membershipTypeValues array I can see the minimum fee has changed to $40
  Any ideas on how to fix this would be great
  Thank you
  
  **Tags:** civicontribute, civimember, php, hooks
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-09-02. Score: 1
  
  I think you need to use [hook\_civicrm\_buildAmount](https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_buildAmount/) or [hook\_civicrm\_buildForm](https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_buildForm/) hook to change the amount on front end contribution/event pages for priceset or line items.
  
  > **Comments:**
  > **username_0**: Thank you, you're right I needed to use buildAmount  
  
  ---
  
  