CiviCRM 4.7.9

I have a custom field that I created for memberships. I would like to have this field displayed as a column within the membership tab when viewing a contact.

I've been digging into the tpl/php files and trying to pin down how to do this, but I keep getting lost.

Can anyone help give me some direction for this?


  • Just as a suggestion, you might want to update your question with the version of Civi you're using... that might help people assist you a little more easily. :-) – Lesley Carter - BackOffice Aug 8 '16 at 15:22

The template you're looking for is templates/CRM/Member/Page/Tab.tpl. The "browse" action is number 16, and takes up the vast majority of the template, starting around line 33.

You'll want to populate the $activeMembers and/or $inActiveMembers array with modified data. Those are defined in CRM_Member_Page_Tab around line 211, but most likely you'll want to modify the $membership array that they're both based on. The browse() method of that function is mostly a "while" loop devoted to building the $membership array, but is sadly devoid of hooks.

| improve this answer | |
  • Where do you think would be the best place to modify that array so that it won't interfere with updates? I know I can create a template override file. Is there a good way to modify it from the TPL? Thanks! – Sleewok Jan 9 '17 at 18:09
  • 2
    You should be able to use hook_civicrm_pageRun to modify the array. To modify the template, there's no great option, though both hook_civicrm_alterTemplateFile and hook_civicrm_alterContent offer a solution. The community-oriented solution would be to rewrite this page to use the core search, which would let you use hook_civicrm_searchColumns after all. Not sure how much work that would be though. – Jon G - Megaphone Tech Jan 9 '17 at 20:24

You can do this using hook_civicrm_searchColumns

More information about the hook in this page: https://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_searchColumns

Hope this helps.

| improve this answer | |
  • I am unable to get it to modify anything for the membership tab. I am able to get it working with the contribution and pledge tabs though. – Sleewok Aug 9 '16 at 21:04
  • 4
    I have verified that it does NOT work for the membership tab. Please see the comment here: civicrm.org/blog/lobo/… – Sleewok Aug 10 '16 at 21:17
  • 1
    hook_civicrm_searchColumns works on searches, not the tabs. The contribution tab happens to use the search functionality to generate the data; memberships doesn't. – Jon G - Megaphone Tech Jan 7 '17 at 23:18

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.