Created
November 8, 2022 16:38
-
-
Save ihslimn/e03d93ff0752037ece783a85cd6fbe1f to your computer and use it in GitHub Desktop.
JetFormBuilder Convert post ID list to post title list
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 | |
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