Answers.Body: <p>You can use profiles directly to create an Household. When you add a field to a profile you have first select the entity, which could be contact, Individual, subtype of Individual, Household, Organization and others.</p>
  
  <p>So there is no need to program this.</p>
  
  <p><a href="https://i.sstatic.net/Z8z3k.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Z8z3k.png" alt="enter image description here"></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-10T12:03:22.937Z
Answers.LastActivityDate: 2018-08-10T12:03:22.937Z
Answers.UserDisplayName: Jaap Jansma - CiviCooP
Body: <p>I am using profile object inside </p>
  
  <pre><code>function hook_civicrm_post($op, $objectName, $objectId, &amp;$objectRef){
  
  }
  </code></pre>
  
  <p>How can I fetch the Profile gid from the above variables? or is there any way to implement it ?<br>
  I want to create a household on submission of a Profile A using custom fields and similarly create an Organization on submission of a Profile B using custom fields.<br>
  So I need a Profile ID which will distinguish between Profile A and Profile B using gid.</p>
  
  <p>The $objectRef variable has the following structure for Profile</p>
  
  <pre><code>Array
      (
          [qfKey] =&gt; f6a85f995860db13425c24378f05c98d_9488
          [entryURL] =&gt; https://example.com/example-registration/?page=CiviCRM&amp;q=civicrm/contribute/transact&amp;
          [email-Primary] =&gt; check@gmail.com
          [first_name] =&gt; check
          [last_name] =&gt; gmail
          [phone-Primary-1] =&gt; 
          [street_address-Primary] =&gt; abc
          [supplemental_address_1-Primary] =&gt; a
          [city-Primary] =&gt; cci
          [postal_code-Primary] =&gt; 30200
          [country-Primary] =&gt; 1013
          [state_province-Primary] =&gt; 1640
          [1] =&gt; 1
          [2] =&gt; 
          [3] =&gt; 
          [4] =&gt; 
          [custom_16] =&gt; Array
              (
                  [1] =&gt; 1
                  [2] =&gt; 
                  [3] =&gt; 
                  [4] =&gt; 
              )
  
          [custom_17] =&gt; 
          [5] =&gt; 
          [custom_1] =&gt; Array
              (
                  [1] =&gt; 1
                  [2] =&gt; 
                  [3] =&gt; 
                  [4] =&gt; 
                  [5] =&gt; 
              )
  
          [custom_18] =&gt; 
          [custom_19] =&gt; Partner check
          [payment_processor_id] =&gt; 0
          [priceSetId] =&gt; 8
          [price_12] =&gt; 40
          [selectProduct] =&gt; 
          [cms_create_account] =&gt; 1
          [cms_name] =&gt; familycheck
          [cms_pass] =&gt; test
          [cms_confirm_pass] =&gt; test
          [MAX_FILE_SIZE] =&gt; 20971520
          [ip_address] =&gt; 192.51.248.26
          [amount] =&gt; 65
          [amount_level] =&gt; 
          [selectMembership] =&gt; 2
          [tax_amount] =&gt; 
          [currencyID] =&gt; AUD
          [is_pay_later] =&gt; 1
          [invoiceID] =&gt; 0c6d15e48854236861cdc16a4a8222e9
          [is_quick_config] =&gt; 1
          [email-5] =&gt; check@gmail.com
          [description] =&gt; Online Contribution: Family Registration
          [accountingCode] =&gt; 
          [addressee] =&gt; 1
          [email_greeting] =&gt; 1
          [postal_greeting] =&gt; 1
          [updateBlankLocInfo] =&gt; 
      )
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-09T09:26:58.007Z
Comments.Text: Could you explain a bit more on the context? On what you want to achieve? Probably the gid is in the objectRef
Comments.UserDisplayName: Jaap Jansma - CiviCooP
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-09T10:22:59.350Z
Comments.Text: Hi @JaapJansma-CiviCooP I have updated the answer, the objectRef does not have it,kindly check it and let me know if your thoughts,Thanks!
Comments.UserDisplayName: harshal
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-10T11:58:55.817Z
Comments.Text: does the objectId hold the id of the profile? If so then you could probably retrive it that way. Waht exactly do you want to achieve?
Comments.UserDisplayName: Jaap Jansma - CiviCooP
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-10T13:41:53.920Z
Comments.Text: Hi @JaapJansma-CiviCooP, I need to create a household using profile field on a contribution Page , but when I try to add a Profile of type Household it gives an error
Comments.UserDisplayName: harshal
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-10T13:43:07.273Z
Comments.Text: $objectId gives profile id which is not gid for the profile
Comments.UserDisplayName: harshal
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-10T15:42:43.620Z
Comments.Text: You have completly lost me. See my answer below how to achieve what you want to achieve.
Comments.UserDisplayName: Jaap Jansma - CiviCooP
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-10T19:12:18.390Z
Comments.Text: Sorry @JaapJansma-CiviCooP to complicate it, but my question would be on how I can differentiate between 2 profiles in hook_civicrm_post? do we have any parameter which can help to check it out?
Comments.UserDisplayName: harshal
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-13T07:33:22.710Z
Comments.Text: You can differentiate between the two profiles with the objectId parameter. That one gives you the ID of the profile
Comments.UserDisplayName: Jaap Jansma - CiviCooP
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-13T07:35:10.427Z
Comments.Text: I am curious why is my answer below not sufficient? It does create a household when you add a household field to the profile
Comments.UserDisplayName: Jaap Jansma - CiviCooP
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-08-13T12:06:03.457Z
Comments.Text: Hello Sir @JaapJansma-CiviCooP, I will mark your answer as correct, It was mistake that I did not add proper question, I was actually trying to add two fields
  1) Household Name
  2) Individual First Name (who would be member of that household)
  When I try to add both Household name and Individual , it does not allow me to do so ,hence I moved to custom profiles,sorry again, you have been very helpful, but I was not able to put the detailed info across to you to answer it.
Comments.UserDisplayName: harshal
Tags: <profile><hooks>
Title: How to fetch Profile gid from hook_civicrm_post included in a Contribution Page?
ThreadText: # How to fetch Profile gid from hook_civicrm_post included in a Contribution Page?
  
  (Asked by: username_0 on 2018-08-09)
  
  I am using profile object inside
  
  ```
  function hook_civicrm_post($op, $objectName, $objectId, &$objectRef){
  
  }
  
  ```
  
  How can I fetch the Profile gid from the above variables? or is there any way to implement it ?  
  I want to create a household on submission of a Profile A using custom fields and similarly create an Organization on submission of a Profile B using custom fields.  
  So I need a Profile ID which will distinguish between Profile A and Profile B using gid.
  
  The $objectRef variable has the following structure for Profile
  
  ```
  Array
      (
          [qfKey] => f6a85f995860db13425c24378f05c98d_9488
          [entryURL] => https://example.com/example-registration/?page=CiviCRM&q=civicrm/contribute/transact&
          [email-Primary] => check@gmail.com
          [first_name] => check
          [last_name] => gmail
          [phone-Primary-1] => 
          [street_address-Primary] => abc
          [supplemental_address_1-Primary] => a
          [city-Primary] => cci
          [postal_code-Primary] => 30200
          [country-Primary] => 1013
          [state_province-Primary] => 1640
          [1] => 1
          [2] => 
          [3] => 
          [4] => 
          [custom_16] => Array
              (
                  [1] => 1
                  [2] => 
                  [3] => 
                  [4] => 
              )
  
          [custom_17] => 
          [5] => 
          [custom_1] => Array
              (
                  [1] => 1
                  [2] => 
                  [3] => 
                  [4] => 
                  [5] => 
              )
  
          [custom_18] => 
          [custom_19] => Partner check
          [payment_processor_id] => 0
          [priceSetId] => 8
          [price_12] => 40
          [selectProduct] => 
          [cms_create_account] => 1
          [cms_name] => familycheck
          [cms_pass] => test
          [cms_confirm_pass] => test
          [MAX_FILE_SIZE] => 20971520
          [ip_address] => 192.51.248.26
          [amount] => 65
          [amount_level] => 
          [selectMembership] => 2
          [tax_amount] => 
          [currencyID] => AUD
          [is_pay_later] => 1
          [invoiceID] => 0c6d15e48854236861cdc16a4a8222e9
          [is_quick_config] => 1
          [email-5] => check@gmail.com
          [description] => Online Contribution: Family Registration
          [accountingCode] => 
          [addressee] => 1
          [email_greeting] => 1
          [postal_greeting] => 1
          [updateBlankLocInfo] => 
      )
  
  ```
  
  **Tags:** profile, hooks
  
  > **Comments:**
  > **username_1**: Could you explain a bit more on the context? On what you want to achieve? Probably the gid is in the objectRef  
  > **username_0**: Hi @JaapJansma-username_1 I have updated the answer, the objectRef does not have it,kindly check it and let me know if your thoughts,Thanks!  
  > **username_1**: does the objectId hold the id of the profile? If so then you could probably retrive it that way. Waht exactly do you want to achieve?  
  > **username_0**: Hi @JaapJansma-username_1, I need to create a household using profile field on a contribution Page , but when I try to add a Profile of type Household it gives an error  
  > **username_0**: $objectId gives profile id which is not gid for the profile  
  > **username_1**: You have completly lost me. See my answer below how to achieve what you want to achieve.  
  > **username_0**: Sorry @JaapJansma-username_1 to complicate it, but my question would be on how I can differentiate between 2 profiles in hook_civicrm_post? do we have any parameter which can help to check it out?  
  > **username_1**: You can differentiate between the two profiles with the objectId parameter. That one gives you the ID of the profile  
  > **username_1**: I am curious why is my answer below not sufficient? It does create a household when you add a household field to the profile  
  > **username_0**: Hello Sir @JaapJansma-username_1, I will mark your answer as correct, It was mistake that I did not add proper question, I was actually trying to add two fields 1) Household Name 2) Individual First Name (who would be member of that household) When I try to add both Household name and Individual , it does not allow me to do so ,hence I moved to custom profiles,sorry again, you have been very helpful, but I was not able to put the detailed info across to you to answer it.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-08-10. Score: 1 | Accepted answer
  
  You can use profiles directly to create an Household. When you add a field to a profile you have first select the entity, which could be contact, Individual, subtype of Individual, Household, Organization and others.
  
  So there is no need to program this.
  
  [![enter image description here](https://i.sstatic.net/Z8z3k.png)](https://i.sstatic.net/Z8z3k.png)
  
  
  ---
  
  