Due to domestic policy reasons, personal website filings do not allow websites to have comment functions. However, a personal blog without an open comment function seems to lack soul. Therefore, we can set it so that only logged-in users can see the comment area content. The specific method is as follows: Find your theme's single.php file, for example, in the Twenty Seventeen theme, locate code similar to the following.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
Modify it as shown below:
if ( is_user_logged_in()){
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
}The method for other themes is similar; you just need to find the corresponding code and add a conditional statement.
`is_user_logged_in` checks whether the user is logged in. If logged in, the comment module will be displayed; if not, it won't load. Of course, after making this modification, you need to enable user registration on your website. You might also be interested in the following articles:
The code in this article is shared by Zhigengniao.
Comments are closed
The comment function for this article is closed. If you have any questions, please feel free to contact us through other channels.