new action: Update Membership Status
This action sets the status of a membership to a configurable value. Also configurable is the option to set the is_override
property to true or false (or leave it unchanged).
The implementation includes adding a PHP class for the already existing Membership Payment trigger, in order to make more entity data available to conditions or actions. The use cases for the new action that we at Civiservice.de foresee do include one where “Membership Payment added” is the trigger. This did not work at first because the table for membership payments includes only the membership ID and contribution ID. As a consequence, in the absence of a trigger class retrieving more data, trigger data for a membership payment does not even include the contact ID, so no conditions on the contact can be used with this trigger up to now. I don’t know if by adding the Membership, Contribution, and Contact entities in full I may have gone too far. Most conditions or actions only need the contact ID and then retrieve the data they need via the API. But I have seen three conditions for contacts that call $triggerData->getEntityData('Contact')
(these conditions are: changed custom field is one of, has type, subtypes changed), so it seemed best to provide that entity. Likewise, the Membership entity is used by one condition (membership has type) and the Contribution entity in several conditions and actions. I have changed trigger.json
to include the trigger class. No extra method for the upgrader seems necessary as in one test I saw that flushing the cache was enough to get the new class entered into the already existing rows in the civirules_trigger
table.
The action itself is straightforward and is mostly a copy of the Add Membership action, only that Add sets a type whereas the new action changes the status and possibly is_override
. Since large parts of the code are copied, I decided to include @jaapjansma in the copyright notices.
We believe that these changes will be very useful for partners who want automatise membership changes, especially in the “German way”. Therefore, if this MR is approved, we would be grateful for a new release. Thanks :-)