Skip to content

Instantly share code, notes, and snippets.

@ihslimn
Created November 8, 2022 16:38
Show Gist options
  • Save ihslimn/e03d93ff0752037ece783a85cd6fbe1f to your computer and use it in GitHub Desktop.
Save ihslimn/e03d93ff0752037ece783a85cd6fbe1f to your computer and use it in GitHub Desktop.
JetFormBuilder Convert post ID list to post title list
<?php
add_action(
'jet-form-builder/form-handler/before-send',
function ( \Jet_Form_Builder\Form_Handler $form_handler ) {
$action_handler = $form_handler->action_handler;
if ( isset( $action_handler->request_data['workshops'] ) ) {
if ( ! is_array( $action_handler->request_data['workshops'] ) ) {
$workshops = array( $action_handler->request_data['workshops'] );
} else {
$workshops = $action_handler->request_data['workshops'];
}
foreach ( $workshops as $id ) {
$post = get_post( $id );
if ( ! $post ) {
continue;
}
$workshops_list[] = $post->post_title;
}
if ( ! empty( $workshops_list ) ) {
$action_handler->request_data['workshops_string'] = implode( ', ', $workshops_list );
}
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment