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?

  • Thinking aloud. Set up Views to access the log_civicrm_membership (or civicrm_membership_log) tables, and then make a block and set to show on summary page
    – petednz - fuzion
    Dec 9, 2020 at 17:57
  • 1
    Hi Pete, Thanks for that idea. I think that might just work. I might even be able to use it to trigger a batch update to create an insert/update on a custom field as well. I will give it a spin and see how it works out. Cheers, Andrew Dec 21, 2020 at 19:13
  • another more off-the-cuff thought would be to add a new field to eg Summary Fields or Synopsis to grab and show this date. also do you know about civicrm.org/extensions/contact-membership-logs
    – petednz - fuzion
    Dec 21, 2020 at 23:26

2 Answers 2


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.


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 and acknowledge you have read our privacy policy.

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