add_filter('forminator_custom_form_submit_field_data', 'custom_form_submit', 11, 2); function custom_form_submit($field_data_array, $form_id){ //Todo: some code return $field_data_array; } https://stackoverflow.com/questions/73498116/how-to-get-submitted-data-from-wordpress-forminator-form-after-sumission
Forminator: Custom multiple upload folder
add_action('forminator_form_after_handle_submit', 'wpmudev_uploaded_filename_fix', 10, 2);
add_action('forminator_form_after_save_entry', 'wpmudev_uploaded_filename_fix', 10, 2);
function wpmudev_uploaded_filename_fix($form_id, $response) {
if ( $form_id != 761 ) {
return;
}
if ( $response && is_array( $response ) ) {
if ( $response['success'] ) {
$attachment_ids = array();
$data = Forminator_CForm_Front_Action::$prepared_data;
if ( !empty( $data['upload-1'] ) ) {
if ( !empty( $data['upload-1']['file']['file_url'] ) ) {
foreach( $data['upload-1']['file']['file_url'] as $key => $file_url ) {
$attachment_ids[] = attachment_url_to_postid($file_url);
}
}
}
// Create a post with a gallery shortcode
if (!empty($attachment_ids)) {
// Create the post title.
$post_title = 'Test-Title';
// Create Post Content using Block Editor Blocks
$post_content = 'test-content';
// Create a new post
$post_data = array(
'post_title' => $post_title,
'post_content' => $post_content,
'post_status' => 'publish',
'post_type' => 'post',
);
$post_id = wp_insert_post($post_data);
// Set the first attached image as the post thumbnail
if ($post_id && !is_wp_error($post_id) && !empty($attachment_ids[0])) {
set_post_thumbnail($post_id, $attachment_ids[0]);
} else {
error_log('Error creating post: ' . print_r($post_id, true));
}
}
}
}
}
Dieser Beitrag hat 0 Kommentare