Skip Navigation

[Resolved] Enable comments on just one CPT by default

This support ticket is created 6 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by Christian Cox 6 years ago.

Assisted by: Christian Cox.

Author
Posts
#1166481

I'd like to enable comments for one CPT only

#1167231
Screen Shot 2018-12-16 at 3.00.17 PM.png
Screen Shot 2018-12-16 at 3.00.24 PM.png

Hi, are you saying you want to enable comments on only one post in a custom post type, or in all posts of only one custom post type?

There are two ways to control comments. Go to Toolset > Post Types and edit the post type. Find the "Sections to display when editing" panel and enable comments using the checkbox. Repeat the process for other post types, and disable comments as needed. This enables or disables the option for comments in a single post type. For more specific comment control, follow the steps above. Then use the comments checkbox in the post editor screen to manage comments per post.

#1167510

Thanks.

I did mean "in all posts of only one custom post type".

I think the solution you have given me allows users in the backend to turn on comments for a single post but what I am trying to do is allow users to create the post in the front end using a CRED form and for comments to be on by default so that others can then comment in the front end.

#1167905

I understand, thanks for clarifying this. I can provide a custom code snippet that will turn comments on for all posts created by a Form. Add this code to your child theme's functions.php file, or to a new snippet in Toolset > Settings > Custom code:

add_action('cred_save_data', 'default_open_comments',10,2);
function default_open_comments($post_id, $form_data)
{
  // if a specific form
  $forms = array( 123,456 );
  if ( in_array( $form_data['id'], $forms ) )
  {
    $args = array('ID' => $post_id, 'comment_status' => 'open');
    wp_update_post($args);
  }
}

Change 123,456 to be a comma-separated list of Form IDs where you want to enable comments for these posts. If it's only one Form, then just one number with no comma is fine.