Answers.Body: <p>This requires you write an extension.  I've written similar extensions to show the "original join date" on a contact summary screen.  If you haven't written PHP, you will probably want to hire someone to do this for you.</p>
  
  <p>Your case is a little trickier, because it'll need to be updated once a..day? Month?  Whereas "original join date" only needs to be filled in once.  </p>
  
  <p>Here's the basic approach:</p>
  
  <ul>
  <li>Create a custom field to store the data.  Set it to view-only.</li>
  <li>In your extension, define a new API.  When the API is called, it should make an API call to find the folks whose custom field will need updating.  If these folks are defined as a group/smart group, that will help!</li>
  <li>Loop through each contact, using the API to query their memberships.</li>
  <li>Take the earliest membership join date that applies and do your math, using PHP's <a href="http://php.net/manual/en/ref.datetime.php" rel="nofollow">date arithmetic functions</a>.</li>
  <li>Use the API to update the field that stores the data.</li>
  <li>Define a scheduled job (<strong>Administer menu » System Settings » Scheduled Jobs</strong>) to run the scheduled job on the schedule of your choice.</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-30T06:19:23.523Z
Answers.Text: Thanks Jon. I figured I might need to build an extension but hoped there was a native method. Oh well... I guess I'll have to poke around in Civi's api explorer to see if I can grab the info, stuff it in a custom field and refresh it once a day. It seems a bit clunky but I guess it'll have to do. Cheers.
Answers.UserDisplayName: Andrew Wasson
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-30T19:22:19.673Z
Answers.Text: Note: If anyone has a native solution, I'm all ears.
Answers.UserDisplayName: Andrew Wasson
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-31T17:02:17.573Z
Answers.Text: PCPs don't yet have an API!  It's on my plate to finish adding them: https://github.com/civicrm/civicrm-core/pull/7878
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-08-30T02:46:50.467Z
Answers.LastActivityDate: 2016-08-30T02:46:50.467Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>I'd like to add a custom field to the Contact Summary page that calculates and displays the time that the person being viewed has held a full membership. </p>
  
  <p>In this case we have student, candidate and full memberships and a full member will have records for each in their membership tab, showing the transition dates from where their student membership ended and candidate membership started, where the candidate membership ended and their full membership started.</p>
  
  <p>For the "Years as Full Member" custom field, we want to be able to glance at the summary page and see that a member has held a full membership for 9 years, 12 years, 25 years, etc... The calculation is simple enough but I don't know how to integrate it within CiviCRM/Drupal.</p>
  
Tags: <custom-fields>
Title: How to add field for length of a specific membership type to Contact Summary page
ThreadText: # How to add field for length of a specific membership type to Contact Summary page
  
  (Asked by: username_0 on 2016-08-29)
  
  I'd like to add a custom field to the Contact Summary page that calculates and displays the time that the person being viewed has held a full membership.
  
  In this case we have student, candidate and full memberships and a full member will have records for each in their membership tab, showing the transition dates from where their student membership ended and candidate membership started, where the candidate membership ended and their full membership started.
  
  For the "Years as Full Member" custom field, we want to be able to glance at the summary page and see that a member has held a full membership for 9 years, 12 years, 25 years, etc... The calculation is simple enough but I don't know how to integrate it within CiviCRM/Drupal.
  
  **Tags:** custom-fields
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-08-30. Score: 1
  
  This requires you write an extension. I've written similar extensions to show the "original join date" on a contact summary screen. If you haven't written PHP, you will probably want to hire someone to do this for you.
  
  Your case is a little trickier, because it'll need to be updated once a..day? Month? Whereas "original join date" only needs to be filled in once.
  
  Here's the basic approach:
  
  * Create a custom field to store the data. Set it to view-only.
  * In your extension, define a new API. When the API is called, it should make an API call to find the folks whose custom field will need updating. If these folks are defined as a group/smart group, that will help!
  * Loop through each contact, using the API to query their memberships.
  * Take the earliest membership join date that applies and do your math, using PHP's [date arithmetic functions](http://php.net/manual/en/ref.datetime.php).
  * Use the API to update the field that stores the data.
  * Define a scheduled job (**Administer menu » System Settings » Scheduled Jobs**) to run the scheduled job on the schedule of your choice.
  
  > **Comments:**
  > **username_0**: Thanks Jon. I figured I might need to build an extension but hoped there was a native method. Oh well... I guess I'll have to poke around in Civi's api explorer to see if I can grab the info, stuff it in a custom field and refresh it once a day. It seems a bit clunky but I guess it'll have to do. Cheers.  
  > **username_0**: Note: If anyone has a native solution, I'm all ears.  
  > **username_1**: PCPs don't yet have an API!  It's on my plate to finish adding them: https://github.com/civicrm/civicrm-core/pull/7878  
  
  ---
  
  