Be careful updating entry meta data. There is an example in the KB that is wrong. The FrmEntryMeta::add_entry_meta() does not check for the existence of a value before writing a new value to the table. You have to do a manual check and then update an existing value or add one as needed. This is the code snippet I use. It's generic and requires 3-parameters to function properly, entry_id, field_key, and value.
https://gist.github.com/vfontjr/f328e0a32b32450fb46e751dade55054#file-frm_entry_meta_example-php
When you use add_entry_meta() without checking for the existence of a previous value, you will end up with multiple values for the same field in the same entry. A view will only pick up the first value. It will appear that add_entry_meta() is not working, but it is. It's just being used incorrectly.
You need to examine the data in PHPMyAdmin to see how this all works.
Yes, thank you. I was already checking this. And if I switch over to using frm_pre_create_entry, I think it becomes irrelevant, though I will still check when using frm_pre_update_entry
Please login or Register to submit your answer