How to prevent editing of comments (as admin) from stripping images
-
On my site, I manually moderate all comments. There are times when it is important for people (not signed-in users) to be able to link to images, so I’ve utilized the
pre_comment_on_post
hook that allows theimg
element to be used when commenting, as such:function adventuretacoplugin_add_post_comment_html_tags( $commentdata ) {
global $allowedtags;
$new_tags = [
'img'=> [
'src'=> true,
'class'=> true,
'style'=> true,
'alt'=> true
]
];
$allowedtags = array_merge( $allowedtags, $new_tags );
}
add_action('pre_comment_on_post', 'adventuretacoplugin_add_post_comment_html_tags' );The problem I am running into is: After a comment is submitted by a non-logged in user, I sometimes notice that there are typos or other issues with the comment content that I want to edit prior to (or immediately after) approval. However, if I edit the contents of the comment created by a non-signed in user in any way from the admin UI (logged in as the admin of the site), the
img
elements are stripped entirely.Is there another action I should be hooking in order to allow the
img
elements in existing comments to persist through edits done via the admin UI?
- You must be logged in to reply to this topic.