I want to record some day-specific information in a user's entry so that when I display their entry using a view, I can display this information. My plan was:
I cannot find the function in the help docs to actually set a value. I have found the ones to get a value, but I need to set it.
This is the function ultimately being called from the user having added and entry, and it works as expected. Just need the code to actually change a value, or understand what would be an alternative way of approaching this.
This help documentation https://formidableforms.com/knowledgebase/set-values-to-be-used-in-custom-displays-or-default-values/ doesn't show any usable PHP, only shortcodes.
function tw_add_day_data_to_entry($entry_id, $form_id ){ $entry = FrmEntry::getOne($entry_id); $user_id = $entry->user_id;
if ( ! $user_id ) { return; //don't continue if no user } // $day = tw_return_status(); $url = tw_home_page()."/day-".$day; echo "Day= ".$day; echo "URL= ".$url; // at this point they return a value $dayURL = FrmProEntriesController::get_field_value_shortcode(array('field_id' ='IDn8jec', 'entry' => $entry_id)); echo $dayURL; $day = FrmProEntriesController::get_field_value_shortcode(array('field_id' ='9q904', 'entry' => $entry_id)); echo $day; }
Note: that update_entry_meta will only work if there's a value already in there for that field. Most of the time it's best to run the update and if false is returned then run FrmEntryMeta::add_entry_meta
Thanks, any idea how I can use the key instead of ID as this would make it so much more versatile for moving the code into prodcution.
Agreed, you should always use keys. I feel strongly that you should always (re)name your keys to know what they are when you're looking at them in code, i.e.., [form_key]_somethingdescriptive, e.g., myformkey_user_first_name. That being said, what you want to do is make use of the key->id and id->key functions that Formidable offers. https://formidableforms.com/knowledgebase/php-examples/#kb-fields
Please login or Register to submit your answer