Use the correct membership date for the notification that appear after completing the membership payment in case pre hook is used
Suppose you have an extension that implements hook_civicrm_pre on membership entity that add 1 year (or whatever amount of time) to the membership new end date whenever someone completed a pending payment for the membership, Based on this assume the following example :
1- You created a pending membership starts today (27/7/2018) and ends in 1 year (26/7/2019). 2- You changed this membership payment (contribution) from "pending" to "completed".
Now without the hook implementation as explained above, the following message will appear :
the contribution record has been saved.
Membership for "CONTACT NAME" has been updated. The membership End Date is July 26th, 2019.
and the membership status will be change from Pending to New, And the end date of the membership will be similar to the one shown in the notification message which is 26/7/2019 which is all good.
But when you have the pre hook implemented as suggest above, the membership end date will be 26/7/2020 (since the hook add one year to the end date) but the notification message will still indicate the old end date which is 26/7/2019. This is wrong and the notification message should show the correct end date that reflects the membership actual end date.