1

I've been thinking about how to best approach this and I'm stumped as to how to best go about it.

I want to add a custom field to a profile that is rendered on the Contact Summary page. I would like to fill it dynamically with the value of the individual's earliest Member Since value.

NOTE: I say the earliest Member Since value because a bug in Civi has changed all Member Since values of currently active membership records to the date of the start of that membership record when they are renewed which ignores the concept that the individual may have had an earlier membership of a different type. The solution is to loop through all memberships and grab the oldest value to populate the custom field with it.

I'm well versed in building custom extensions and working in custom code. This is for a Drupal 7 / CiviCRM site. Any ideas or direction?

0

How immediately do you need this field's value to be set? If it can be delayed, I'd probably do this as a cron script that loops through all that aren't set yet and then sets its value.

I'm assuming also you're familiar with the "View only" checkbox at the bottom of the custom field definition form - that would be how I'd create this field.

0

Thinking out loud......

  • create an extension with perhaps an API that accepts a contact_id as a param and returns the oldest membership start date
  • assuming you know in advance what the member since should be you could use the buildForm hook to change the value (using the API or doing the calculation in a a specific class)
  • alternatively add a little jQuery (using the CRM_Core_Region, see https://docs.civicrm.org/dev/en/latest/framework/region/) to the form that replaces the core value with the "correct" value using the API request?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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