Description

Action that fires during form entry processing, after initial field validation has passed.

Parameters

$post_id
int (Required) Post ID.
$fields
array Sanitized entry field values/properties.
$form_data
array Form settings/data.
$entry_id
int (Required) Entry ID.

Source

wpforms-post-submissions/class-post-submissions.php

More Information

The wpforms_post_submissions_process action fires after the fields have been validated, during the entry saving process.

This action will save the entry and begin creating the post from the submission.

Examples

The example shown below will create some custom meta fields to assign to the post using WordPress Custom Fields creation.

This is example is going to build the social follow links for each author submitted post on the form ID 1159.

/**
 * Action fires after form submission and validation.
 *
 * @link   https://wpforms.com/developers/wpforms_post_submissions_process/
 * 
 * @param  int      $post_id     Post ID.
 * @param  array    $fields      Sanitized entry field values/properties.
 * @param  array    $form_data   Form settings/data.
 * @param  int      $entry_id    Entry ID.
 *
 * @return array
 */

function wpf_dev_post_submissions_process( $post_id, $fields, $form_data, $entry_id ) {

    // Only do this for form #1159.
    if ( absint( $form_data['id'] ) !== 1159 ) {
        return;
    }

    /*
     * Field IDs, for reference.
     * 21 - Twitter URL
     * 22 - Facebook URL
     * 23 - Dribble URL
     * 24 - Instagram URL
     */

    // Below we're going to create our new custom content template,
    // using the field IDs listed above 
    ob_start();
    ?>
    <h2><em>Author Social Follow Links</em></h2>
    <div class="social_links"> 
    <a href="<?php echo esc_url( $fields[21]['value'] ); ?>" target="_blank"><img src="<?php echo get_template_directory_uri(); ?>/images/twitter.png" class="author_social_follow" width="80" height="80" alt="Follow me on Twitter!" /></a>
    <a href="<?php echo esc_url( $fields[22]['value'] ); ?>" target="_blank"><img src="<?php echo get_template_directory_uri(); ?>/images/facebook.png" class="author_social_follow" width="80" height="80" alt="Follow me on Facebook!" /></a>
    <a href="<?php echo esc_url( $fields[23]['value'] ); ?>" target="_blank"><img src="<?php echo get_template_directory_uri(); ?>/images/dribbble.png" class="author_social_follow" width="80" height="80" alt="Follow me on Dribbble!" /></a>
    <a href="<?php echo esc_url( $fields[24]['value'] ); ?>" target="_blank"><img src="<?php echo get_template_directory_uri(); ?>/images/instagram.png" class="author_social_follow" width="80" height="80" alt="Follow me on Instagram!" /></a>
    </div>
    <?php
    $content = ob_get_clean();

    remove_filter('content_save_pre', 'wp_filter_post_kses');
    remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');

    $post = array(
        'ID'           => $post_id,
        'post_content' => $content,
    );
    wp_update_post( $post );

    add_filter('content_save_pre', 'wp_filter_post_kses');
    add_filter('content_filtered_save_pre', 'wp_filter_post_kses');
}
add_action( 'wpforms_post_submissions_process', 'wpf_dev_post_submissions_process', 10, 4 );

Snippet Reference: How to Build a Profile Form Using Post Submissions