Update notifications for certain fields or by certain users

By: Jane Onorati | Asked: 02/06/2024
ForumsCategory: Code HelpUpdate notifications for certain fields or by certain users
Jane OnoratiJane Onorati asked 2 months ago
I want to get a notification email every time certain fields (but not all fields) are updated on the front end.  I found this snippet thanks to Rob: https://formidableforms.com/knowledgebase/frm_pre_update_entry/#kb-check-if-value-has-changed which is a good start.  However, I'd like to know if there is a way to add the previous values that were changed to the email notification.  The previous values are obtained from the database by this snippet, but I don't know how to add them to the email notification message using php. I'd also like to be notified if either certain users, certain user roles, or just non-administrators updated an entry. The only ways I know of to access "Updated by" field values are by viewing entries in the backend table or looking at a .csv file of downloaded entries. -Jane
2 Answers
Rob LeVineRob LeVine answered 2 months ago
For the "adding them to the email notification" issue, let's say you have a field "Date" and you want to show it along with the "Old Date". Make the "Old Date" field hidden by any of the available methods. Use frm_pre_update_entry to write the old values into the "old" fields. From there, you can set up two separate notification actions where one shows both old & new fields and the other only shows the new values (you can use the exclude_fields to do that.
Rob LeVineRob LeVine answered 2 months ago
For the notification part, you can set up a notification (set it to disable so it only fires when you want) and then in the frm_after_update_entry hook you check to see who updated it (get the user_id from get_current_user_id()) and trigger the property notification by using the info in this tutorial.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right