Answers.Body: <p>you should be able to do this with the buildForm hook that is described here: <a href="https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_buildForm/" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_buildForm/</a>.
  Keep in mind that the custom fields are actually posted on a different form, so I usually first dump the form names to the log with <code>Civi::log()-&gt;debug</code> so I can check what the name I need is.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-16T15:59:55.007Z
Answers.Text: Thanks for your recommendations, finally, I found the form that works with the custom fields in the memberships: CRM_Custom_Form_CustomDataByType
Answers.UserDisplayName: Cesar
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-16T06:52:29.973Z
Answers.LastActivityDate: 2018-10-16T06:52:29.973Z
Answers.UserDisplayName: ErikH - CiviCooP
Body: <p>Its possible to set default values of a membership custom fields through a civiCRM hook? 
  I have seen that the values are generated by ajax when membership type is changed but i dont see any hook for this.</p>
  
  <p>thanks!</p>
  
Tags: <webform-civicrm>
Title: Set defaults values and attributes to membership form fields with PHP
ThreadText: # Set defaults values and attributes to membership form fields with PHP
  
  (Asked by: username_0 on 2018-10-15)
  
  Its possible to set default values of a membership custom fields through a civiCRM hook?
  I have seen that the values are generated by ajax when membership type is changed but i dont see any hook for this.
  
  thanks!
  
  **Tags:** webform-civicrm
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-10-16. Score: 2
  
  you should be able to do this with the buildForm hook that is described here: <https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_buildForm/>.
  Keep in mind that the custom fields are actually posted on a different form, so I usually first dump the form names to the log with `Civi::log()->debug` so I can check what the name I need is.
  
  > **Comments:**
  > **username_0**: Thanks for your recommendations, finally, I found the form that works with the custom fields in the memberships: CRM_Custom_Form_CustomDataByType  
  
  ---
  
  