Support » Plugin: Post My CF7 Form » How to set comment allow on a post published?

  • Resolved Pensebien

    (@pensebien)


    I was able to use the publish filter to set the Post to Contact Form and also the redirect filter. Both work perfectly but I would love to know how to set commenting and choose a particular template to use.

    My approach to use this filter wp_insert_post_data in the funtion.php file for any of the post that are submitted via the plugin.

    But I think there could be a better approach since this filter

    add_filter( 'cf7_2_post_status_post', 'publish_new_post',10,3);
    function publish_new_post($status, $ckf7_key, $submitted_data){
      return 'publish';
    }

    There could be a filter for setting commenting.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Aurovrata Venet

    (@aurovrata)

    There could be a filter for setting commenting.

    there is, search ‘cf7_2_post_register_post_{post_type}’ in the plugin page. You need to tweak the support attribute to enable comments.

    Thank you @aurovrata for the immediate reply. Do you mean the filter cf7_2_post_register_post_{post_type} is in the plugin and I would need to use register_post_type to update my post?
    Presently this is what I have tried but it is not working. I made a unique category and added wp_insert_post action. like so

    add_action( 'wp_insert_post', 'set_commenting_for_specific_taxonomy', 10, 2 );
    
    function set_commenting_for_specific_taxonomy( $post_ID, $post )
    {
      $category_name = "The name of category";
      $categories = get_the_category($post_ID);
      if (in_array($categories, $category_name)) {
         remove_filter(current_filter(), __FUNCTION__ );
         $post->comment_status = 'open';
         wp_update_post( $post );
      }
    }

    I feel there I could tweak the code to add the comment_status set to “open” when the post is created rather after it is created. Love to hear your thoughts.

    • This reply was modified 2 months, 2 weeks ago by Pensebien.
    Plugin Author Aurovrata Venet

    (@aurovrata)

    Presently this is what I have tried but it is not working. I made a unique category and added wp_insert_post action

    if you need commenting only on certain posts, then I guess this would be the way to do it…although I admint I have no experience in managing/configuring comments. so if you have some suggestions as to how to do it, please feel free to suggest, or even better, do a PR on the GitHub repo 🙂

    cf7_2_post_register_post_{post_type} is in the plugin and I would need to use register_post_type to update my post?

    yes, except that with this hook you can filter the $args (arguments array) of the register_post_type function, allowing you to fully customise your post type and therefore enable comments for all posts.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    I would also like to help out in editing the README.

    by all means, there is plenty work on this plugin which needs improvement, not leas the documentation/readme. So I am all ears if you have some suggestions. I presonally prefer in-page help as much as possible, which is what I started doing.

    yes, except that with this hook you can filter the $args (arguments array) of the register_post_type function, allowing you to fully customize your post type and therefore enable comments for all posts.

    I would try this method.

    if you need commenting only on certain posts, then I guess this would be the way to do it…although I admint I have no experience in managing/configuring comments. so if you have some suggestions as to how to do it, please feel free to suggest, or even better, do a PR on the GitHub repo 🙂

    If I can abstract it properly, I would add a PR. Thanks!

    Plugin Author Aurovrata Venet

    (@aurovrata)

    ok, good luck! reach out in the Github repo for further contributions/fixes.

    I am akring this thread as resolved for now. Feel free to reach out if you are still stuck.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.