agileware / wp-civicrm-ux

WordPress CiviCRM UX - User Experience enhancements
GNU General Public License v2.0
7 stars 12 forks source link

Display contact or membership custom field #7

Closed jbonlinea closed 2 years ago

jbonlinea commented 3 years ago

Hi there,

Is it possible to display civi custom field tied to contact, and/or to membership, with this module ?

I have successfully used the plug-in to display contact details like such [ux_contact_value field=first_name] or membership details like such [ux_membership_status] thank's to the documentation.

contact custom field

I've tried [ux_contact_value field=Statut] "Statut" being the field name in Civi (see capture below) but nothing is returned (I also have tried "statut'.

membership custom field

similarly, I do have added civi custom field to membership. However I don't see the [ux_membership_xxx] shortcode offering a "field" parameter to display the custom field we want.

Regards

ps : sorry the screenshot is in french, but it in civi > administer > customise data and screens > custom data.

Capture du 2021-03-18 18-47-28

agileware-justin commented 3 years ago

@jbonlinea you can definitely display any contact, custom field. See https://github.com/agileware/wp-civicrm-ux/blob/master/shortcodes/contact/value.php#L63 - that line just passes the field name you supply to the CiviCRM API and asks for a value to be returned.

However, there is no implementation of this functionality for membership, custom fields at all. We rarely (if ever) use custom fields on membership and thus have not had a need to add this feature. The model to implement would be similar to getting contact custom fields.

Alternately, you could solve this problem by setting up a Data Processor for the membership and display the custom fields you wanted. Then it's a matter of using the ux_civicrm_listing shortcode to display the results on the page.

jbonlinea commented 3 years ago

Hi,

Thank's for the clarifications. I usually try to rely on as few add-on, and code customisation as possible to secure long-term compatibility or autonomy, and ease set-up, maintenance or day to day use, etc., but the data processor indeed offer an flexible and extensive route.

If I may ask, what kind of "output" shoud I select in the data processor in order to use it with ux_civicrm_listing shortcode ?

I've create the processor, added membership in data source and my_custom_field in field, but there are quite many output option. I guess few may work depending of what we want to display and that your shortcode parameter "format" may be set to be in line with the data processor output format, but trying all the combination to find the one which work would take an insane amount of time.

Thank's again !

agileware-justin commented 3 years ago

Just a FYI. This is now possible as we've implemented the ability to call the CiviCRM APIv4 directly via shortcode.

We haven't updated the documentation yet (sorry!), but the feature was introduced with this commit, https://github.com/agileware/wp-civicrm-ux/commit/0fcc53d4791ba09c91d0787ace6dac8db91f7122

jbonlinea commented 3 years ago

:+1:

thank's for the heads up

agileware-justin commented 2 years ago

CiviCRM APIv4 shortcode is definitely the way to go here.