Gravity Wiz

Magically enhanced tutorials, snippets and plugins for Gravity Forms!

  • Gravity Perks
    • Gravity Perks
    • Tutorials & Snippets
    • About
  • Support
    • Documentation
    • Support
    • Account

Close Comments when Post Created via Gravity Forms

Last updated August 21, 2019 | Written by David Smith 2 Comments

This simple snippet allows you to close comments on posts created via a Gravity Form.

Download Code
/**
* Close Comments when Post Created via Gravity Forms
* http://gravitywiz.com/2012/04/25/close-comments-when-post-created-via-gravity-forms/
*/
// update the '6' to the ID of your form
add_filter('gform_post_data_6', 'gform_close_comments');
function gform_close_comments($post_data){
$post_data['comment_status'] = 'closed';
return $post_data;
}
view raw gistfile1.php hosted with ❤ by GitHub

Did this resource help you do something awesome with Gravity Forms? Then you'll absolutely love Gravity Perks; a suite of 32+ essential add-ons for Gravity Forms with support you can count on.

  • View All Perks
  • Buy Gravity Perks

Filed Under: Snippets

Comments

  1. Allan Schmidt says

    September 28, 2012 at 4:37 pm

    This would only close comments from one GF created post/form, yes?

    Reply
    • David Smith says

      September 28, 2012 at 7:16 pm

      This would close comments on each created by the form ID your specify in the filter name or all forms if you remove the form ID completely from the filter name.

      It would only impact posts created after the snippet is implemented.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Categories

  • How To (64)
  • News (21)
  • Plugins (14)
  • Releases (7)
  • Resource (3)
  • Snippets (58)
  • Tutorials (57)
  • Updates (104)

Recent Posts

  • How to Send a Follow-Up and Pre-Fill Information
  • How to Update Posts with Gravity Forms
  • Gravity Wiz Weekly #104
  • The Complete Guide to Using Gravity Forms With Zapier
  • Gravity Wiz Weekly #103

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Copyright © 2021 · Powered by WordPress · Gravity Wiz LLC

  • Support
  • Affiliates
  • About
  • Sitemap
  • Gravity Perks
    ▼
    • Gravity Perks
    • Tutorials & Snippets
    • About
  • Support
    ▼
    • Documentation
    • Support
    • Account