Skip to content

Instantly share code, notes, and snippets.

@ronalfy
Created July 14, 2015 01:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ronalfy/6b4fec8b3ac55bc47f3f to your computer and use it in GitHub Desktop.
Save ronalfy/6b4fec8b3ac55bc47f3f to your computer and use it in GitHub Desktop.
Simple Comment Editing - Logged In Users Only
<?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