Elementor meta updater code?
Hi, ich habe hier diesen Code geschrieben um mit Elementor Formularen bestimmte meta daten zu aktualisieren aber dieser scheint keine wirkung zu haben, nach dem absenden passiert garnichts, wäre echt cool wenn jemand Helfen würde
function update_metafield_on_form_submission( $record, $ajax_handler ) {
$form_settings = $record->get( 'form_settings' );
$form_fields = $form_settings['form_fields'];
// The "field-id" here needs to be the field that has the metafoeld data
$metafield_value = $record->get_field( 'form-field-test1' );
// This 'post-id' is the ID of the post where the metafield you want to change is
$post_id = 12779;
// Replace 'metafield-key' with the key of the metafield you want to update
update_post_meta( $post_id, 'test', $metafield_value );
}
2 Antworten
Da fehlt ja auch der Code, welcher die Funktion aufruft.
Also sowas wie add_filter() oder add_action() am richtigen Hook...
Hast du überprüft, ob die ID des Formular-Felds ("form-field-test1'") und die ID des Posts ("12779") sowie der Name der Metadaten stimmt?