Skip to content

Instantly share code, notes, and snippets.

@vfontjr
Last active October 21, 2024 12:28
Show Gist options
  • Save vfontjr/f328e0a32b32450fb46e751dade55054 to your computer and use it in GitHub Desktop.
Save vfontjr/f328e0a32b32450fb46e751dade55054 to your computer and use it in GitHub Desktop.
Updating From Entry Meta
<?php
function add_or_update_entry_meta( $entry_id, $field_key, $value ){
/* convert field_key to field_id for software portability */
$field_id = FrmField::get_id_by_key($field_key);
/* check for existing value */
$field_val_exists = FrmProEntriesController::get_field_value_shortcode(array('field_id' => $field_id, 'entry' => $entry_id));
/* add or update as appropriate */
if ( !empty( $field_val_exists ) ) {
$result = FrmEntryMeta::update_entry_meta( $entry_id, $field_id, '', $value );
} else {
$result = FrmEntryMeta::add_entry_meta( $entry_id, $field_id, '', $value );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment