• I’ve added some filters to allow admin level users to simple edit user comments. If a user edits their own comment, and cancels, then edits again, everything is fine. If admin level does the same thing, the text edit box on the second attempt ends up blank.

    Viewing HTML of the browser shows there is text in the box, but changing it has no effect.

    Any ideas?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Ronald Huereca

    (@ronalfy)

    Can you share a gist of your code?

    Thread Starter Brad Mettee

    (@bmettee4)

    Nothing terribly complicated about this. No modifications to any core or SCE source code either.

    Also found out, admin level user has same problem on their own comments, not just others.

    Here’s the code:`
    // hook into the sce_allow_delete filter, dis-allow users from deleting their comments unless nwf_allow_comment_delete capability is true (capability available on contributor and above)
    function nwf_allow_comment_delete($allow_delete)
    {
    $allow_delete = !$allow_delete ? current_user_can(‘nwf_allow_comment_delete’, true) : $allow_delete;
    return $allow_delete;
    } // nwf_allow_comment_delete
    add_filter( ‘sce_allow_delete’, ‘nwf_allow_comment_delete’, 100);

    // hook into sce_unlimited_editing to allow site admin/editor to edit any comment, regardless of how long it’s been up
    function nwf_sce_unlimited_comment_edit($allow, $comment)
    {
    $allow = !$allow ? current_user_can(‘editor’, true) : $allow;
    return $allow;
    } // nwf_sce_unlimited_comment_edit
    add_filter( ‘sce_unlimited_editing’, ‘nwf_sce_unlimited_comment_edit’, 1, 2);

    // hook into sce_cookie_bypass to allow site admin/editor to edit any comment, regardless of how long it’s been up
    function nwf_sce_can_edit_cookie_bypass($bypass, $comment, $comment_id, $post_id, $user_id )
    {
    if ( $bypass || current_user_can(‘editor’, true) ) return true;
    if ( 0 != $user_id && $comment->user_id == $user_id )
    {
    $bypass = true;
    }
    return $bypass;
    } // nwf_sce_can_edit_cookie_bypass
    add_filter( ‘sce_can_edit_cookie_bypass’, ‘nwf_sce_can_edit_cookie_bypass’, 10, 5);`

    • This reply was modified 5 years, 8 months ago by Brad Mettee.
    Thread Starter Brad Mettee

    (@bmettee4)

    I’m also hooking comment_text filter. (there’s an open issue at github about it too, but it can be worked around for now)

    
    // make any external links in a comment be opened in a new window/tab by adding 'target="_blank"' to the 'a' tag
    function nwf_comment_text($content, $comment)		// should have 3 but simple comment editing only sends 2, $args)
    	{
    	$content = nwf_links_add_target($content, '_blank');
    	return $content;
    	}  //  nwf_comment_text
    add_filter('comment_text', 'nwf_comment_text', 100, 2);
    
    Thread Starter Brad Mettee

    (@bmettee4)

    Has the above code been helpful?

    I’ve also determined that an Admin level has the same problem editing their own comments. Edit once, cancel, can’t edit again until page reload.

    Plugin Author Ronald Huereca

    (@ronalfy)

    I honestly haven’t had a chance to test it. Been crazy busy. I did fix the filters though. I’ll try to look at it tonight.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘edit by admin, cancel, blanks edit if you try again’ is closed to new replies.