Is it possible to extract the target contact ID of a form during hook_civicrm_buildForm?
We are trying to manipulate a wide range of fields across the site, ones that might be present in event registration forms, contact profile forms, etc.
We want to disable editing of the field if there is a value in it, and the contact has a certain value on their record.
The workflow we have in mind is...
- Is 'Field A' on the form?
- If yes, does 'Field A' have a value already?
- If yes, is there a 'target contact' for the form (ie: a logged in user is registering for an event, or updating their profile)
- If yes, fire an API call to get the value of 'Field X' from the record of the target contact.
- If 'Field X' is 'Yes' then disable editing of 'Field A' on the form.
We understand that not all forms will have a target contact ID, and we would only want to go through this logic if there was one. So it wouldn't do any of this if an anonymous user was signing up to an event; but would if a logged-in user was.
The logic itself isn't the problem, but we can't seem to find the target contact ID stored anywhere at this point.
Thanks in advance!