I need help with why the save function is not working in the edit_comment hook.
Here is the code for the 'comment_post' hook:
add_action( 'comment_post', 'save_comment_meta_data' );
function save_comment_meta_data( $comment_id ) {
if ( ( isset( $_POST['private'] ) ) && ( $_POST['private'] != '') )
$private = wp_filter_nohtml_kses($_POST['private']);
add_comment_meta( $comment_id, 'private', $private );
}
And here is the 'edit_comment' hook:
add_action( 'edit_comment', 'extend_comment_edit_metafields' );
function extend_comment_edit_metafields( $comment_id ) {
if( ! isset( $_POST['extend_comment_update'] ) || ! wp_verify_nonce( $_POST['extend_comment_update'], 'extend_comment_update' ) ) return;
if ( ( isset( $_POST['private'] ) ) && ( $_POST['private'] != '') ) :
$private = wp_filter_nohtml_kses($_POST['private']);
update_comment_meta( $comment_id, 'private', $private );
else :
delete_comment_meta( $comment_id, 'private', $private );
endif;
}
This adds a checkmark box in the edit window to make the comment private.
The checkmark box appears but it does not save when I update the comment in the edit window. Any idea why?
private
a checkbox or a text field? You seem to be conflating the data types in your whitelisting code.