30

March

Hiding wpDiscuz comments on a membership site running WP eMember

There is a glitch we found when developing a membership site using WP eMember and using the fantastic commenting system wpDiscuz: the comments on protected pages were not being hidden by WP eMember even though we explicitely protected them in the system settings.

WP eMember successfully hides standard WordPress comments, but we really wanted all the extra features of wpDiscuz, so we had to find a workaround.

After some complicated solutions that caused more problems than it was worth, the final solution was simple and elegant.

We use the Genesis framework here, but this code will work in any functions.php file.

<?php
add_action('get_header','emember_fns');
function emember_fns() {
  if(!wp_emember_is_member_logged_in()){ 
    remove_post_type_support( 'post', 'comments' );
  }
}
?>

Because we use custom post types in our system, we replaced ‘post' on line 7 with our cpt name. You can do a series of these in a row, if you have multiple page types with comments you want to hide (post, page, any custom post type.)

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Use this Bottom Section to Promote Your Offer


New

  • Lorem ipsum dolor sit amet, consectetur adipiscing elit
  • Duis aute irure dolor in reprehenderit
  • Excepteur sint occaecat cupidatat