WordPress background Display related user articles associated with comments

Source: Internet
Author: User
Tags comments wordpress database

Add the following code to the functions.php file for the current topic:

The code is as follows Copy Code

//Background only shows comments on current User Article Association On
function Wpdx_get_comment_list_by_user ($clauses) {
        if (is_admin ()) {
                global $user _ ID, $wpdb;
                $clauses [' Join '] = ", wp_posts";
                $clauses [' where ' ]. = "and Wp_posts.post_author =". $user _id. " and wp_comments.comment_post_id = Wp_posts.id ";
       };
        return $clauses;
};
if (!current_user_can (' edit_others_posts ')) {
Add_filter (' comments_clauses ', ' wpdx_get_comment_list_by_ User ');
}

Note: If your wordpress database prefix is not the default WP_, please change the wp_ in line 5th and 6 to the database prefix of your WordPress site.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.