【发布时间】:2013-11-19 18:20:19
【问题描述】:
当用户在他/她已经评论过的节点上遇到时,我想在我的评论表单中隐藏 Fivestar 评级字段(称为“field_stars”)。我的网站上有一个名为 Commented 的标志,还有一个规则,当有人对其进行评论时代表评论员标记节点(效果很好)。我试图解决我的问题,根据我找到的信息here:
function hiderating_form_alter(&$form, &$form_state, $form_id) {
global $user;
$flag = flag_get_flag('commented') or die('no "commented" flag defined');
if ($form_id == "comment_node_stuff_form") {
if ($flag->is_flagged($form['#node']->uid, $user->uid)) {
unset($form['field_stars']);
}
}
}
不幸的是,它并没有改变任何东西(我也没有收到任何错误)。我做错了什么?
使用@jerdiggity 的代码进行调试后,我得到:
DEBUG: form id "comment_node_stuff_form" found. Debugging...
DEBUG: The code $flag->is_flagged($form["#node"]->uid, $user->uid) is returning FALSE.
(当然,我也收到了DEBUG: final form structure:,但粘贴在这里太长了)。我不明白为什么无法识别标记,因为它存储在数据库中...
【问题讨论】:
标签: php drupal-7 drupal-comments drupal-fivestar