CoursePress Discussions not working

Hi Gurus,

I just tried testing the course discussion feature. I was able to "Ask a question" but there doesn't appear to be a way to respond to questions? I couldn't find a link or button to respond to a question. Is this a bug or am I misunderstanding this feature?

How do I format the "Ask a Question" button?

  • Predrag Dubajic

    Hi emilio_gagliardi,

    Discussion questions should show default WP comment form but I can indeed see that this is not the case with your installation.

    I also had a look at your default posts and I can't see comment section there as well even though they are enabled.
    It looks like this is something specific to your installation so I would suggest performing basic troubleshooting by disabling your plugins and switching to default WP theme in order to see what's causing this behaviour on your site.

    Best regards,
    Predrag

  • Dimitris

    Hey there emilio_gagliardi,

    hope everything's going well for you today! :slight_smile:

    And I don't have any of the default themes on my site. I guess this feature just won't work for me.

    Default and much much more free themes can be downloaded right through admin page here
    yourdomain.com/wp-admin/theme-install.php

    Feel free to try TwentySixteen from there which should display the comments section correctly. If this is the issue indeed, you should try to change your theme I'm afraid or have a developer to further assist you by enabling those if this is too much for you. Our Jobs & Pros section is a cool place to advise. :slight_smile:

    Kind regards,
    Dimitris

  • emilio_gagliardi

    Hi Dimitris,

    Is the "Discussion" option in CoursePress Pro handled through shortcodes or are there functions that handle the process? I'm curious if I can make my own discussion page for each course?

    I think part of the problem is that page specific comments aren't enabled by default and I'm wondering if I can create the "Discussion" page through my Page Builder so that I can enable Comments on the page?

    Is there a way to create a custom "Discussion List" and "Discussion" page template? I feel like if its possible then I can get the discussions working through the Facebook+ plugin.

    Thanks kindly,

  • Dimitris

    Hello emilio_gagliardi,

    Is the "Discussion" option in CoursePress Pro handled through shortcodes or are there functions that handle the process? I'm curious if I can make my own discussion page for each course?

    There's a mix of shortcodes and PHP code, all located in template parts(files) that CoursePress embeds to your theme and can be found in /wp-content/plugins/coursepress/includes/templates/ folder.

    I think part of the problem is that page specific comments aren't enabled by default and I'm wondering if I can create the "Discussion" page through my Page Builder so that I can enable Comments on the page?

    As long as your theme builder does provide a "comments" section or anything similar, this may be possible. Otherwise, I guess a theme change should be applied for better results, like getting back the default WP comment system.

    Is there a way to create a custom "Discussion List" and "Discussion" page template? I feel like if its possible then I can get the discussions working through the Facebook+ plugin.

    The following files in your child theme can handle the "discussion list" and "single discussion page".
    archive-discussions.php
    single-discussions.php

    Hope that was some help, feel free to post back here if more assistance is required!
    Warm regards,
    Dimitris

  • emilio_gagliardi

    Two more issues.
    When I use Facebook Comments, the "comments" count is NOT set correctly. Is it possible to fix this?
    How do I remove the [0 comments] from "Discussion List"

    How do I adjust the H1 font-size for just Discussion items? The CSS class is:

    class="et_pb_post post-29170 discussions type-discussions status-publish hentry"

    but I don't want to have the solution be post specific. Is it possible to generate a CSS selector for all Discussion Titles?

    Thanks kindly,

  • Adam Czajczyk

    Hello emilio_gagliardi!

    I think the problem is that post-type="discussions" are default setting the comment_status="closed"

    This should be taken from WP settings but seems like may not be fully compatible with the theme. There's no "SQL statement" or any "setting/hidden code" that would make it "open" by default so the solution would be like my colleague Dimitris suggested: a custom page template.

    In this case you'd just need to make sure that the template includes comment form and it should do the job.

    Alternatively, you could "programatically unblock" comments for discussion pages with following code:

    <?php
    add_filter( 'comments_open', 'my_comments_open', 10, 2 );
    function my_comments_open( $open, $post_id ) {
    	$post = get_post( $post_id );
    	if ( 'discussions' == $post->post_type )
    		$open = true;
    	return $open;
    }

    To apply it to the site:
    - create an empty file with a .php extension (e.g. "enable-cp-discussions.php")
    - put the code inside
    - upload the file to the "/wp-content/mu-plugins" on your server.

    This would make WordPress set to keep comments open on each post of "discussions" type so on all courses discussions pages. If your theme will handle this, it should fix the issue so give it a try please.

    When I use Facebook Comments, the "comments" count is NOT set correctly. Is it possible to fix this?

    This is referring to the course discussions pages or other parts of the page as well?

    How do I remove the [0 comments] from "Discussion List"

    As for this and H1 issue. This would be doable with some simple CSS but may depend on the theme so I'd need to check it on your site. Would you mind granting me a support access to it again? Here's a guide:

    https://premium.wpmudev.org/manuals/wpmu-dev-dashboard-enabling-staff-login/

    Best regards,
    Adam

  • emilio_gagliardi

    Hi Adam,

    Thanks for your help here.
    1) Did you want me to upload "enable-cp-discussions.php" file outside the "plugins" directory and create a new directory called "mu-plugins"? or did you mean create the directory "mu-plugins" inside the existing "plugins" directory?
    wp-content/plugins/mu-plugins/enable-cp-discussions.php (I created file here with code you provided)
    -or-
    wp-content/mu-plugins/enable-cp-discussions.php

    2) Under CoursePress "Discussions". When I use Facebook comments, the comment counts displayed on the "Discussion List" page do not reflect the number of Facebook comments.

    3) [0 comments] was referring to the image, I'll reattach it.

    4) I granted WPMU Dev access.

    Thank you kindly,

  • Dimitris

    Hey there emilio_gagliardi,

    1) This should be the correct path of the MU plugin
    wp-content/mu-plugins/enable-cp-discussions.php
    just like Adam stated.

    2) I can see no FB comments at the moment. Could we proceed by enabling FB comments and see that in action? Please advise!

    3,4) Use the following CSS rules in your theme's custom CSS area

    h1.discussion-title {
      font-size: 20px;
    }
    .discussion-archive-list .comments-count {
      display: none;
    }

    Warm regards,
    Dimitris

  • emilio_gagliardi

    Hi Dimitris,

    Thank you.
    1) I moved enable-cp-discussion.php to correct location. Do I need to enable it or something for it to take effect? It doesn't appear to be correcting the problem. Under the "Course Stream" Course Discussions, there are four discussions. The newest Discussion Topic, does not display the Facebook Comments object, whereas the oldest 3 do have Facebook comments enabled because I manually changed their comment status to "open" in the database.

    This Discussion Topic has two Facebook comments: http://growing.ecoevolver.com/discussions/what-is-the-biggest-challenge-you-have-to-overcome-to-start-growing-food/

    This Discussion topic has no Facebook comments: http://growing.ecoevolver.com/discussions/what-aspects-of-climate-change-affect-you-directly/

    How do I change the font-size & text-transformation of Discussion titles viewed as a standalone topic?

    Lastly, the sub navigation doesn't display when viewing Discussion topics on standalone page.

  • Predrag Dubajic

    Hi Emilio,

    #1 mu-plugins stands for must use plugins and plugins added there will be automatically activated until removed from that folder, so it should work out of the box.

    I'm not sure why this is not working for you but can you try taking a bit different approach by replacing Adam's code with this one:

    <?php
    function default_comments_on( $data ) {
        if( $data['post_type'] == 'discussions' ) {
            $data['comment_status'] = 'open';
        }
    
        return $data;
    }
    add_filter( 'wp_insert_post_data', 'default_comments_on' );

    How do I change the font-size & text-transformation of Discussion titles viewed as a standalone topic?

    You should be able to change it with this CSS code:

    .discussions h1.discussion-title {
        font-size: 20px;
        text-transform: none;
    }

    Lastly, the sub navigation doesn't display when viewing Discussion topics on standalone page.

    Are you now running custom single-discussions.php template on your site?

    Also, I'm having issues using support access on your site so could you please revoke it and grant it again, this usually takes care of that?

    Best regards,
    Predrag

  • emilio_gagliardi

    Hi Predrag,

    I reset the Support Access, hopefully, that now works correctly? I just bought a domain name to point to the sub directory I am using.

    I am not running a custom single-discussions.php template on my site. Was I supposed to make one? I made mu-plugins/enable-cp-discussions.php, but that's it.

    Thank you so much for the above code, unfortunately, comments are still closed. I edited the mu-plugins file and replaced the code with what you provided above. When I load a Discussion item that I haven't set to 'open' through SQL, the comments are disabled for that topic.

    The CSS you provided for the discussion title didn't work. :slight_frown:

    I appreciate you looking into this!

  • Dimitris

    Hey there emilio_gagliardi,

    hope you're doing good today! :slight_smile:

    I reset the Support Access, hopefully, that now works correctly?

    This didn't make the trick unfortunately. I keep redirecting to the login page, is there any kind of security plugin that you're running? Could you please disable it and let us know to try again?

    I am not running a custom single-discussions.php template on my site. Was I supposed to make one? I made mu-plugins/enable-cp-discussions.php, but that's it.

    It seems that the workaround that Adam provided and Predrag altered a bit, won't work with your theme. What can be done now is to create a custom single discussion page. To do so, you should duplicate the single.php file of your parent theme to the child theme folder and rename it to single-discussions.php.
    Then, you should enter the appropriate discussion-related content as can be found either in the default CoursePress built-in theme
    (/wp-content/plugins/coursepress/themes/coursepress)
    or in the template parts(files) that CoursePress embeds to other themes
    (/wp-content/plugins/coursepress/includes/templates/).

    You should also make sure that wp_list_comments() and comment_form() functions are included so that comments will be displayed eventually.

    Please keep in mind that this kind of custom development surpasses the scope of this support forum and you may have to hire an experienced developer for that (you may use our Jobs & Pros section for this kind of custom work).

    The CSS you provided for the discussion title didn't work.

    Could you please try this one instead?

    .single-discussions .entry-title {
      font-size: 20px;
      text-transform: none;
    }

    Warm regards,
    Dimitris

  • emilio_gagliardi

    OMG, I finally got the WPMU Dashboard to sync to the Hub...blarg, changing the domain name screwed things up, sorry everyone.

    Hopefully you can log in now!

    I appreciate all the time you've invested to help drill down to the problem. It sounds like I need to create a custom page template to handle discussions with the Divi theme.

    To be clear, you're saying the file, "mu-plugins/enable-cp-discussion.php" does not solve the problem, so I should delete that file and folder moving forward.

    I will investigate making a custom discussion template and see if I can get it working.

    Thank you kindly,

  • Dimitris

    Appreciate your kind words here! :slight_smile:

    To be clear, you're saying the file, "mu-plugins/enable-cp-discussion.php" does not solve the problem, so I should delete that file and folder moving forward.

    This shouldn't cause any conflicts right now, so feel free to leave it as is for time being.
    Whenever you have a single discussion view the way you want and comments are working properly, you can test removing this snippet. :wink:

    Take care,
    Dimitris