Last active
October 21, 2024 12:28
-
-
Save vfontjr/f328e0a32b32450fb46e751dade55054 to your computer and use it in GitHub Desktop.
Updating From Entry Meta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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