Skip to content

Instantly share code, notes, and snippets.

@kimwhite
Last active January 3, 2021 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kimwhite/c14bb79a0f3d19cbf9314f883a7473ed to your computer and use it in GitHub Desktop.
Save kimwhite/c14bb79a0f3d19cbf9314f883a7473ed to your computer and use it in GitHub Desktop.
<?php
/**
* This recipe will hide comments from non logged in users.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
if ( ! function_exists( 'see_comments_after_login' ) )
{
add_filter( 'comments_template', 'see_comments_after_login', 11 );
function see_comments_after_login( $comments_template )
{
return is_user_logged_in() ? $comments_template : __FILE__;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment