Post title overwritten on update

Issue #40 new
Robert Jones created an issue

I'm using the following code to update a post via a gravity form:

<?php $id = get_the_id();
echo do_shortcode('[gravityform id="4" title="false" description="false" update="'.$id.'"]'); ?>

On updating the form my ACF fields are updated but the standard WordPress title gets changed to "Update_2", if I update again it just changes to "Update_3" and so on.

The CPT post already had a title, as soon as I updated it just changes to the above.

All plugins and core are running the latest as of this point.

Comments (1)

  1. Robert Jones reporter

    I've solved this but seems there's a bug in the plugin. I've just added on a hook to override the title after submission. It doesn't solve the initial problem, it just corrects it after.

    add_action( 'gform_after_submission_4', 'set_post_content', 10, 2 );
    function set_post_content( $entry, $form ) {
    
        //getting post
        $post = get_post( $entry['post_id'] );    
        $post->post_title = rgar( $entry, '8' ) . ' ' .rgar( $entry, '9' );
    
        //updating post
        wp_update_post( $post );
    }
    
  2. Log in to comment