admin管理员组文章数量:1128466
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.
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 asked Feb 7, 2013 at 10:44 dexBerlindexBerlin 1255 bronze badges1 Answer
Reset to default 1Have you tried
$subscriber= get_role('subscriber');
$subscriber->add_cap('edit_comment');
NOTE
edit_comment
is only supported in verson 3.1 or later
This worked for me , hope it helps you!
本文标签: commentseditcomment capability for subscriber
版权声明:本文标题:comments - edit_comment capability for subscriber 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736724014a1949631.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论