For those wanting to edit comments, you can’t go wrong with Comment Edit Core and unlimited editing.
One highly requested feature is the ability to edit comments indefinitely. Let’s go over how to do that with this plugin.
Using code to enable perpetual editing
To enable unlimited editing, you would create a site-specific plugin or use something like Code Snippets to insert the code.
Here’s the code you would use for unlimited editing:
<?php
/**
* Plugin Name: Unlimited Editing
* Description: Allow users to edit their comments without time limit.
* Version: 1.0
*
* @param bool $enabled
* @param WP_Comment $comment
*/
function myprefix_enable_unlimited_editing( $enabled, $comment ) {
if ( ! is_user_logged_in() ) {
return false;
}
global $current_user;
$user_id = absint( $current_user->ID );
if ( absint( $comment->user_id ) !== $user_id ) {
return false;
}
return true;
}
add_filter( 'sce_unlimited_editing', 'myprefix_enable_unlimited_editing', 12, 2 );
Code language: PHP (php)
We’re using filter sce_unlimited_editing
, which passes a boolean and a comment object.
If the user isn’t logged in or the commenter’s user ID dosn’t match the current user, then unlimited editing should be off. Otherwise, return true
.
Enable unlimited editing with a plugin
If code is not your thing, then I recommend checking out Comment Edit Pro. You can enable unlimited editing in the Comment Editing section.
Conclusion
In this “how to”, I went over how to enable unlimited editing in Comment Edit Core.