Settings for displaying unreplied comments and comments of the current user in the WordPress background

Source: Internet
Author: User
Tags comments trim

The function diagram we want to implement is as follows:


I searched the internet and found that there is a plug-in DX Unanswered Comments (Download address) that can implement this function. Just upload and install the plug-in, and then go to the background? Set? DX Unanswered Comments: Fill in the administrator login name in the Authors List. Multiple login names are separated by commas and saved.

Then go to the WordPress background? Comments: a Non-replied filtering link is added to the top of the page. Click it to view comments that the administrator has not replied to. Is there a Non-replied filtering link? Top Level. Only Top-Level comments not replied by the administrator are displayed.

But the official version of this plug-in has some problems, may not work properly, we need to make some modifications, open with a text editor: dx-unanswered-comments \ inc \ dxuc-helper.class.php

Search:
$ User = get_user_by ('Slug', trim ($ username ));
Use the following code:
$ User = get_user_by ('login', trim ($ username ));

As for Chinese, we can find in dx-unanswered-comments \ dx-unanswered-comments.php:
_ ('Non-replicased', 'dxuc ')
Changed:
_ ('Unrecoverable ', 'dxuc ')

Search:
_ ('Non-replied-Top level', 'dxuc ')
Changed:
_ ('Unreplied-top-level ', 'dxuc ')

Finally, use UTF-8 encoding as a dx-unanswered-comments.php.



How does one display only the comments of the current user in the WordPress background comment list?

If you're talking about the comments list page edit-comments.php, you can add the following code to the topic's functions. php so that only the user's comments are displayed on this page:

/*** Display the comments of the current user (and the comments in the published articles) */add_filter ('The _ comments ', 'wpdx _ filter_comments '); function wpdx_filter_comments ($ comments) {global $ pagenow; global $ user_ID; get_currentuserinfo (); // If you need to display comments in the current user's article, delete the following comments/* and */// current_user_can ('Publish _ posts') to indicate that the current user is the "author" role, you can limit the role by modifying parameters, refer to the http://codex.wordpress.org/Roles_and_Capabilities if ($ pagenow = 'edit-comments. php '/* & current_user_can (' Publish_posts ') */) {foreach ($ comments as $ I => $ comment) {$ the_post = get_post ($ comment-> comment_post_ID ); // if you need to display the comments in the current user's article, delete the following comments/* and */if ($ comment-> user_id! = $ User_ID/* & $ the_post-> post_author! = $ User_ID */) unset ($ comments [$ I]) ;}} return $ comments ;}


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.