CoursePress - Unit page comments

I feel like I'm missing something very basic. How do I add commenting to a page within a course unit? Initially I added Facebook commenting in the single-unit.php file, but I want to try WordPress comment system. I don't remember if I turned off a setting somewhere when I implemented Facebook comments...

  • Michael Bissett
    • Recruit

    Hey @msk5400! :slight_smile:

    In regards to this:

    How do I add commenting to a page within a course unit?

    Could you elaborate on where on the page you're looking to insert a comment area? (please attach a screenshot here)

    Given that there's already the "Discussion" section (which can be enabled for a course by checking the "Allow Course Discussion" in "Step 5 - Classes, Discussion & Workbook"), could you also elaborate on why you're wanting to add a comment box please?

    Kind Regards,
    Michael

  • msk5400
    • Site Builder, Child of Zeus

    I want a comment area below all the learning content of each page of a unit. This enables students to comment specifically on the content of that page. Discussions is course-wide and too general for my purpose. I want to be able to prompt the student within my video on the unit page to "enter a comment below and tell me..."

  • Predrag Dubajic
    • Support

    Hey @msk5400,

    Hope you're well today :slight_smile:

    Answer Field is not visible by other course participants as it is intended to be used as an answer from current student and graded depending on the answer.

    There is another thing you can try tho, install our WordPress Chat plugin and now you will see new field when creating units called Chat, this will allow your users to chat about the video or any content on that page.

    Hope this helps.

    Best regards,
    Predrag

  • Michelle Shull
    • DEV MAN’s Apprentice

    Hey, Mike!

    How do you feel about inline comments? CoursePress uses a special template, so adding the WP comment field isn't as easy as dropping it in a template. I did some testing on my own site, however, and I found this plugin: https://wordpress.org/plugins/inline-comments/

    It works on CoursePress content, because it shows depending on CSS selector. I used .entry-content p and H1 as my selectors, that gave a comment bubble option next to each paragraph in the course unit and description. I took a screenshot of what the interface looks like on my theme. You can drill down into the various CSS selectors in CoursePress content to customize exactly where and what you'd like to allow commenting on. Inline comments are pretty modern, I can't say for sure it won't end up being a fad, rather than the wave of the future, but they do look pretty cool.

    If this isn't an option, let me know and we can brainstorm some more. :slight_smile:

    • msk5400
      • Site Builder, Child of Zeus

      Hi Michelle,

      I appreciate the suggestion, but this is not the solution for me. I just need a comments area at the bottom of the unit page (either WordPress or Disqus). I can't believe this is so difficult... Isn't there a line of code I can add to the theme or plugin somewhere?

  • Predrag Dubajic
    • Support

    Hi @msk5400,

    I must say I'm out of ideas here, I tried few things but didn't manage to get this to work since each course is seen as a post with unique ID instead of a each unit.

    I am tagging an available developer from second level support line in this thread for his valuable opinion on this issue. Please note that, developer response might be slower than usual staff response, so we appreciate your patience on this.

    Best regards,
    Predrag

  • Vinod Dalvi
    • WP Unicorn

    Hi @ msk5400 ,

    I think you are using CoursePress theme on your site so to allow comments on unit page, add the attached unit-comments.php file in the root folder of your child theme and add the following code just before the end of while loop in your child theme single-unit.php file.

    <?php
                $file = '/unit-comments.php';
                if( file_exists( STYLESHEETPATH . $file ) ){
                        require( STYLESHEETPATH . $file );
                }
                ?>

    Also add the following code in the functions.php file of your child theme.

    add_post_type_support('unit','comments');
    
    global $wpdb;
    $wpdb->update( $wpdb->posts, array( 'comment_status' => 'open'),  array('post_type' => 'unit'), array( '%s'),array('%s') );

    Best Regards,
    Vinod Dalvi

  • Vinod Dalvi
    • WP Unicorn

    Hi @ msk5400,

    I have tested it again on my test site using latest version of CoursePress plugin and the provided changes worked fine for me, enabling comments on the unit page.

    Would you mind if I access your site using FTP and did some testing? This might help get to the bottom of this faster. If this is ok, just send log in info through our secured contact form: https://premium.wpmudev.org/contact/
    - Choose "I have a different question"
    - Include my name in the subject "Vinod Dalvi"
    - Include the URL of this post in your message so that I may track this issue better
    - Include login information (Wordpress admin info username + password )
    - Include FTP Details

    Regards,
    Vinod Dalvi

  • Michael Bissett
    • Recruit

    Hey @msk5400,

    Regarding this code snippet:

    <?php
                $file = '/unit-comments.php';
                if( file_exists( TEMPLATEPATH . $file ) ){
                        require( TEMPLATEPATH . $file );
                }
                ?>

    Since you're using a child theme on your site, I had to change "TEMPLATEPATH" to "STYLESHEETPATH" (the former would be always attempting to look in the parent theme, whereas with the latter, the folder of the active theme would be used, which in this case would be your child theme):

    <?php
                $file = '/unit-comments.php';
                if( file_exists( STYLESHEETPATH . $file ) ){
                        require( STYLESHEETPATH . $file );
                }
                ?>

    I'm now seeing that the comments form is showing up on your site, could you confirm the same please? :slight_smile:

    Kind Regards,
    Michael

  • Michelle Shull
    • DEV MAN’s Apprentice

    Hey there, Mike!

    I've left a note for Michael to revisit here. I believe this will take a different solution entirely, because Vinod/Michael's solution relies on the WordPress comment template. Tying into the Discus system may be quite a bit more complicated here.

    He'll swing by as soon as he's able, thanks for your patience here!

  • Vinod Dalvi
    • WP Unicorn

    Hi Mike,

    The Disqus Comments replaces the default WordPress comments by hooking in to the filter comments_template as following.

    add_filter('comments_template', 'dsq_comments_template');

    This filter only gets executed when we use the following comments_template function to include the comments file but in your custom code we are using the require function to include it therefore it's not getting added on the unit page.

    http://codex.wordpress.org/Function_Reference/comments_template

    We are not using in our custom code the comments_template function as it's not working out of the box.

    It can be made to work but it will require more complex custom coding and developing custom code for custom functionality is beyond the scope of support that we provide. See here : https://premium.wpmudev.org/manuals/using-wpmu-dev/support-vs-custom-development/

    If you are not a programmer then you can consider hiring a developer from https://premium.wpmudev.org/wpmu-custom-development/ to develop it for you.

    I have not tested it but you can try using the code like following or applying the filter comments_template in the custom code using the apply_filters function.

    <?php
    $file = '/unit-comments.php';
    if( function_exists('dsq_comments_template') ){
    	dsq_comments_template(STYLESHEETPATH . $file);
    }
    ?>

    Cheers,
    Vinod Dalvi

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.