[resolved] Edit Comment not working (4 posts)

  1. wildkyo
    Posted 5 years ago #

    Hi guys!

    I've tried to get working the Edit Comment Capability with WordPress 3.1 Beta 1 but I can't. As I understand Contributors now can Edit Comments so if you put the edit_comment_link() function then Contributors must see the link to edit his comments. But it doesn't!

    Anyway I tried to add the capability manually but I've the same result.

    if (current_user_can('contributor')
    add_action('admin_init', 'allow_contributor_comments');

    function allow_contributor_comments() {
    $contributor = get_role('contributor');

    So, is this option available? Anyone can please give me a hand on this?

  2. Andrew Nacin
    Lead Developer
    Posted 5 years ago #

    This simply won't work.

    edit_comment is a meta capability. It gets re-mapped to another meta capability, edit_post (which may change depending on the post type), which is then mapped to the primitive capabilities (what users and roles have).

    For a contributor to moderate any comment means that you need to let them edit all posts.

    Or, you can just drop a filter on map_meta_cap() to do this. (No role modifications needed, except to also give them the moderate_comments cap.)

    It would look something like this (wholly untested):

    function nacin_contributors_can_moderate_comments( $caps, $cap ) {
       if ( $cap == 'edit_comment' )
         $caps = array( 'edit_posts' );
       return $caps;
    add_filter( 'map_meta_cap', 'nacin_contributors_can_moderate_comments', 10, 2 );
  3. wildkyo
    Posted 5 years ago #

    Oh hell... I misunderstood it. Thanks for the explanation! I thought that this new capability allow users to edit their own comments but I see that I was wrong. I don't understand why WordPress doesn't have yet this capability like "edit_own_comments" or something similar.

    Thank you very much for your reply and explanation!

  4. Andrew Nacin
    Lead Developer
    Posted 5 years ago #

    Ultimately, we can't change the way core currently works, such that authors can moderate comments on their own posts. But we can make it easier for plugins to modify it.

Topic Closed

This topic has been closed to new replies.

About this Topic