• Resolved KostasNi

    (@kostasni)


    I am using Gravity Forms to let (logged in) site users submit posts from the front end. I’ve setup BNFW to send 2 “New Post Published” notifications when a new post is submitted: one to the admin and one to the user. This works great.

    I also use Gravity Forms and the Gravity Forms Post Updates plugin so that an admin can update these posts from the front end. I want to send a notification to the post submitter when their post has been updated by the admin so I’ve created a “Post Updated” notification. However when the post is edited on the front end, instead of the “Post Updated” notification, the 2 “New Post Published” notifications are sent instead.

    When a post is updated using Gravity Forms and Gravity Forms Post Updates, the post’s post_status is first changed to “draft” and then to “publish” again, which triggers the “New Post Published” notifications.

    Is there a way to check if the post_status was changed twice (publish->draft, draft->publish) and send the “Post Updated” instead of the “New Post Published” notification?

    ps. This issue has been reported in the past: Issue with Gravity Forms

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author bnfw

    (@voltronik)

    Hi @kostasni,
    Thanks for your message.

    Have you contacted the Gravity Forms Post Updates plugin author about this too? A two pronged approach might work well in resolving this, if possible.

    Thanks,
    Jack

    Thread Starter KostasNi

    (@kostasni)

    Thanks for getting back to me @voltronik.

    Gravity Forms Post Updates doesn’t seem to be actively maintained or supported. I’ve posted a support topic there as well: Unwanted Post Status change on update.

    Plugin Author bnfw

    (@voltronik)

    Hi @kostasni,
    Ok. Let me know how it goes with the developer if he comes back to you.

    In the meantime, have you considered editing the other plugin?

    Thanks,
    Jack

    Thread Starter KostasNi

    (@kostasni)

    Hi Jack,
    The problem ended up being not with the Gravity Forms: Post Updates plugin, but with the way Gravity Forms handles the post creation/update.

    Specifically, GF changes the post’s post_status to draft

    // remove original post status and save it for later
    $post_status = $post_data['post_status'];
    
    // replace original post status with 'draft' so other plugins know this post is not fully populated yet
    $post_data['post_status'] = 'draft';

    and then changes it back to whatever it was

    
    // update post status back to original status (if not draft)
    if ( $post_status != 'draft' ) {
        $post = is_object( $post ) ? $post : get_post( $post_id );
        $post->post_status = $post_status;
    } 
    

    It was the second change, draft to publish, that triggered the draft_to_publish hook which Better Notification for WordPress uses.

    To prevent the “New Post” notifications, you need to eliminate the draft to publish change.

    I accomplished that by first changing the post_status to something other than publish (I used ’temp_status’) and then after GF does it’s thing, changing it back to publish. I also added a second post_update at the end to trigger the publish_to_publish hook and send the “Post Updated” notification.

    I hope this helps anyone who runs into the same issue in the future.

    • This reply was modified 7 years, 10 months ago by KostasNi. Reason: formatting
    Plugin Author bnfw

    (@voltronik)

    Hi @kostasni,
    Thanks for your reply.

    So pleased you got it working and thanks for posting a comprehensive answer on how to fix this issue should anyone else run into the problem.

    If you like BNFW and the support, please feel free to leave an honest review.

    Thanks,
    Jack

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Wrong notification on Post Update with Gravity Forms Post Updates plugin’ is closed to new replies.