0

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] => [email protected]
        [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] => [email protected]
        [description] => Online Contribution: Family Registration
        [accountingCode] => 
        [addressee] => 1
        [email_greeting] => 1
        [postal_greeting] => 1
        [updateBlankLocInfo] => 
    )
10
  • Could you explain a bit more on the context? On what you want to achieve? Probably the gid is in the objectRef Commented Aug 9, 2018 at 9:26
  • 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!
    – harshal
    Commented Aug 9, 2018 at 10:22
  • 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? Commented Aug 10, 2018 at 11:58
  • 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
    – harshal
    Commented Aug 10, 2018 at 13:41
  • 1
    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.
    – harshal
    Commented Aug 13, 2018 at 12:06

1 Answer 1

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.