[wp-meta] [Making WordPress.org] #7177: Allow Seemingly Anonymous forum post Edits

Making WordPress.org noreply at wordpress.org
Sat Apr 20 04:53:31 UTC 2024


#7177: Allow Seemingly Anonymous forum post Edits
----------------------------+---------------------
 Reporter:  Ipstenu         |       Owner:  (none)
     Type:  enhancement     |      Status:  new
 Priority:  normal          |   Milestone:
Component:  Support Forums  |  Resolution:
 Keywords:  has-patch       |
----------------------------+---------------------

Comment (by developerhub):

 Implementing such a feature would require some customization within the
 WordPress platform. You'd likely need to create a custom plugin or modify
 your theme's functions.php file to achieve this functionality. Here's a
 general outline of the steps you might take:

 1. **Create a Custom Plugin or Modify Functions.php**: If you're
 comfortable with coding, you can create a custom plugin to handle this
 feature. Alternatively, you can modify your theme's functions.php file.

 2. **Hook into WordPress Actions**: You'll need to hook into the
 appropriate WordPress actions to intercept the display of usernames and
 modify them as needed. For example, you might hook into the
 `get_the_author` filter.

 3. **Check if User is Logged In**: Within your custom function, you'll
 need to check if the user is logged in. You can do this using WordPress
 functions like `is_user_logged_in()`.

 4. **Check if User is a Moderator**: Depending on how your moderation
 system is implemented, you'll need to determine if the user performing the
 action is a moderator. This might involve checking user roles or using
 custom user metadata.

 5. **Modify Display Name**: If the conditions are met (i.e., the action is
 performed by a moderator and the user is logged in), modify the display
 name to 'WordPress Moderation Team'.

 6. **Display Logic**: Ensure that this modification only applies to
 certain areas of your site where moderation actions are displayed.

 Here's a basic example of what the code might look like (in this case,
 modifying the display name on post comments):

 ```php
 function modify_comment_author_name( $author ) {
     if ( is_user_logged_in() ) {
         $user = wp_get_current_user();
         // Check if the user is a moderator (you'll need to customize this
 logic)
         if ( current_user_can( 'moderate_comments' ) && $user->ID !=
 get_the_author_meta( 'ID' ) ) {
             return 'WordPress Moderation Team';
         }
     }
     return $author;
 }
 add_filter( 'get_comment_author', 'modify_comment_author_name' );
 ```

 This is just a basic example, and you'll need to adapt it to fit your
 specific use case and moderation setup. Additionally, you may need to
 consider performance implications if you're modifying a large number of
 comments or other content. Testing thoroughly on a development environment
 is recommended before implementing on a live site.
 Replying to [ticket:7177 Ipstenu]:
 > Related to #6839, #5718, #5717
 >
 > When a post is edited by anyone, it puts in their name and the time.
 >
 > By default, if the action is done by a moderator and it's **NOT** their
 own post, this should show as 'WordPress Moderation Team' instead of the
 user name, but only to the logged in users.
 >
 > All other mods and cape wearers should be able to see which Mod did
 what, for accountability.
 >
 > Right now, we have a checkbox for 'don't log edit'
 >
 > I recommend we ''remove'' that, and change it to an auto-checked "log
 edit as anon"

-- 
Ticket URL: <https://meta.trac.wordpress.org/ticket/7177#comment:10>
Making WordPress.org <https://meta.trac.wordpress.org/>
Making WordPress.org


More information about the wp-meta mailing list