Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have given my site's subscriber role the following permissions (unserialized DB-query):

[subscriber] => Array
    (
        [name] => Reader
        [capabilities] => Array
            (
                [delete_comment] => 1
                [edit_comment] => 1
                [level_0] => 1
                [quick_edit_comment] => 1
                [read] => 1
                [reply_comment] => 1
                [unfiltered_html] => 1
            )

    )

I want to make the subscriber be able to edit their comments, but I always get an error "Your are not allowed to edit this comment." I tried the following in debugging (in my comments.php template file):

$link = get_edit_comment_link($GLOBALS['comment']->comment_ID);
$perm1 = current_user_can('edit_comment', $GLOBALS['comment']->comment_ID);
$perm2 = current_user_can('edit_comment');
var_dump($link);
var_dump($perm1);
var_dump($perm2);
global $current_user;
var_dump($current_user->allcaps);

giving the following output (explanation added beside):

(get_edit_comment_link): NULL
(cur_user w/ post-id): bool(false)
(cur_user w/o post-id): bool(false)

(allcaps): 
array(9) { ["delete_comment"]=> bool(true) ["edit_comment"]=> bool(true) 
["edit_posts"]=> bool(true) ["level_0"]=> bool(true) ["quick_edit_comment"]=> bool(true) 
["read"]=> bool(true) ["reply_comment"]=> bool(true) ["unfiltered_html"]=> bool(true) 
["subscriber"]=> bool(true) } 

As you can see, the allcaps shows that the user is allowed to edit_comments. But get_edit_comment_link stays empty, although the role has the capability AND the current_user is the author of the comment.

share|improve this question

1 Answer 1

Have you tried

$subscriber= get_role('subscriber'); $subscriber->add_cap('edit_comment');

NOTE eidt_comment is only supported in verson 3.1 or later

This worked for me , hope it helps you!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.