March 30, 2019

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.)


Get Sagely

Sign up for regularly broadcasted emails on
running your online business and thriving

during the craziest times most of us have ever lived.

__CONFIG_colors_palette__{"active_palette":0,"config":{"colors":{"0ed48":{"name":"Main accent","parent":-1}},"gradients":[]},"palettes":[{"name":"Default","value":{"colors":{"0ed48":{"val":"var(--tcb-skin-color-0)"}},"gradients":[]},"original":{"colors":{"0ed48":{"val":"rgb(47, 138, 229)","hsl":{"h":210,"s":0.77,"l":0.54,"a":1}}},"gradients":[]}}]}__CONFIG_colors_palette__
__CONFIG_colors_palette__{"active_palette":0,"config":{"colors":{"f8570":{"name":"Main Accent","parent":-1}},"gradients":[]},"palettes":[{"name":"Default Palette","value":{"colors":{"f8570":{"val":"var(--tcb-local-color-0ed48)"}},"gradients":[]},"original":{"colors":{"f8570":{"val":"rgb(19, 114, 211)","hsl":{"h":210,"s":0.83,"l":0.45}}},"gradients":[]}}]}__CONFIG_colors_palette__
Sign Up

Related Articles

April 9, 2019

If you already have a great PDF giveaway for your subscribers, you've probably set up your autoresponder to fire off a link to the free resource upon subscription. It's easy peasy, and everyone is ...

Read More

May 3, 2018

About a year ago we started a small test / pet project and ran it privately on a shared hosting account. We brought in a contractor to do some development on it for us, ...

Read More

Want Results?

__CONFIG_colors_palette__{"active_palette":0,"config":{"colors":{"3e1f8":{"name":"Main Accent","parent":-1}},"gradients":[]},"palettes":[{"name":"Default Palette","value":{"colors":{"3e1f8":{"val":"var(--tcb-skin-color-0)"}},"gradients":[]},"original":{"colors":{"3e1f8":{"val":"rgb(19, 114, 211)","hsl":{"h":210,"s":0.83,"l":0.45}}},"gradients":[]}}]}__CONFIG_colors_palette__
Let's Chat