Created
July 14, 2015 01:59
-
-
Save ronalfy/6b4fec8b3ac55bc47f3f to your computer and use it in GitHub Desktop.
Simple Comment Editing - Logged In Users Only
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Requires PHP >= 5.3 | |
add_filter( 'sce_can_edit', function( $can_edit, $comment_obj, $comment_id, $post_id ) { | |
//Make sure user is logged in | |
if ( !is_user_logged_in() ) { | |
return false; | |
} | |
//Get current user id | |
$user = wp_get_current_user(); | |
$user_id = $user->ID; | |
//Check if comment author is same as current user | |
if ( (int)$comment_obj->user_id === $user_id ) { | |
return true; | |
} | |
return false; | |
}, 10, 4 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment