admin管理员组文章数量:1026989
I have a poll, the vote of which must be closed for guests.
<ol class="zf-structure-list zf-quiz_answer zf-text zf-clearfix">
<?php
if( isset( $question["answers"] ) ) {
foreach ($question["answers"] as $answer) {
?>
<li class="zf-answer-item <?php if (isset($_COOKIE["zf_poll_vote_ans_" . $answer["answer_id"]])) echo 'zf-selected'; ?>"
data-voted="<?php echo isset($poll_results["answers"][$answer["answer_id"]]) ? $poll_results["answers"][$answer["answer_id"]] : 0 ?>"
data-id="<?php echo $answer["answer_id"]; ?>" data-post-id="<?php the_ID() ?>"
data-group-id="<?php echo $question["question_id"]; ?>"
data-voted-group="<?php echo isset($zombify_poll_results["groups"][$question["question_id"]]) ? $zombify_poll_results["groups"][$question["question_id"]] : 0 ?>">
<div class="zf-answer js-zf-answer">
<div class="zf-checkbox-wrp"></div>
<div class="zf-poll-stat"></div>
<div class="zf-poll-stat_count"></div>
<div class="zf-answer_text">
<?php echo $answer["answer_text"]; ?>
</div>
</div>
</li>
<?php
}
} ?>
</ol>
How to make that polls show for the guest, but when you click on the zf-answer-item, nothing happened?
Thanks!
I have a poll, the vote of which must be closed for guests.
<ol class="zf-structure-list zf-quiz_answer zf-text zf-clearfix">
<?php
if( isset( $question["answers"] ) ) {
foreach ($question["answers"] as $answer) {
?>
<li class="zf-answer-item <?php if (isset($_COOKIE["zf_poll_vote_ans_" . $answer["answer_id"]])) echo 'zf-selected'; ?>"
data-voted="<?php echo isset($poll_results["answers"][$answer["answer_id"]]) ? $poll_results["answers"][$answer["answer_id"]] : 0 ?>"
data-id="<?php echo $answer["answer_id"]; ?>" data-post-id="<?php the_ID() ?>"
data-group-id="<?php echo $question["question_id"]; ?>"
data-voted-group="<?php echo isset($zombify_poll_results["groups"][$question["question_id"]]) ? $zombify_poll_results["groups"][$question["question_id"]] : 0 ?>">
<div class="zf-answer js-zf-answer">
<div class="zf-checkbox-wrp"></div>
<div class="zf-poll-stat"></div>
<div class="zf-poll-stat_count"></div>
<div class="zf-answer_text">
<?php echo $answer["answer_text"]; ?>
</div>
</div>
</li>
<?php
}
} ?>
</ol>
How to make that polls show for the guest, but when you click on the zf-answer-item, nothing happened?
Thanks!
Share Improve this question edited Jan 2, 2019 at 17:55 Tom J Nowell♦ 61.2k7 gold badges79 silver badges150 bronze badges asked Jan 2, 2019 at 16:59 Grosso2020Grosso2020 1 1 |1 Answer
Reset to default 0You can check user logged in with is_user_logged_in
. This is a simple function to check user logged in or not. Can you try this?
<ol class="zf-structure-list zf-quiz_answer zf-text zf-clearfix">
<?php
if(is_user_logged_in()){
if( isset( $question["answers"] ) ) {
foreach ($question["answers"] as $answer) {
?>
<li class="zf-answer-item <?php if (isset($_COOKIE["zf_poll_vote_ans_" . $answer["answer_id"]])) echo 'zf-selected'; ?>"
data-voted="<?php echo isset($poll_results["answers"][$answer["answer_id"]]) ? $poll_results["answers"][$answer["answer_id"]] : 0 ?>"
data-id="<?php echo $answer["answer_id"]; ?>" data-post-id="<?php the_ID() ?>"
data-group-id="<?php echo $question["question_id"]; ?>"
data-voted-group="<?php echo isset($zombify_poll_results["groups"][$question["question_id"]]) ? $zombify_poll_results["groups"][$question["question_id"]] : 0 ?>">
<div class="zf-answer js-zf-answer">
<div class="zf-checkbox-wrp"></div>
<div class="zf-poll-stat"></div>
<div class="zf-poll-stat_count"></div>
<div class="zf-answer_text">
<?php echo $answer["answer_text"]; ?>
</div>
</div>
</li>
<?php
}
}
} else {
echo 'Please login to show these poll';
}?>
</ol>```
I have a poll, the vote of which must be closed for guests.
<ol class="zf-structure-list zf-quiz_answer zf-text zf-clearfix">
<?php
if( isset( $question["answers"] ) ) {
foreach ($question["answers"] as $answer) {
?>
<li class="zf-answer-item <?php if (isset($_COOKIE["zf_poll_vote_ans_" . $answer["answer_id"]])) echo 'zf-selected'; ?>"
data-voted="<?php echo isset($poll_results["answers"][$answer["answer_id"]]) ? $poll_results["answers"][$answer["answer_id"]] : 0 ?>"
data-id="<?php echo $answer["answer_id"]; ?>" data-post-id="<?php the_ID() ?>"
data-group-id="<?php echo $question["question_id"]; ?>"
data-voted-group="<?php echo isset($zombify_poll_results["groups"][$question["question_id"]]) ? $zombify_poll_results["groups"][$question["question_id"]] : 0 ?>">
<div class="zf-answer js-zf-answer">
<div class="zf-checkbox-wrp"></div>
<div class="zf-poll-stat"></div>
<div class="zf-poll-stat_count"></div>
<div class="zf-answer_text">
<?php echo $answer["answer_text"]; ?>
</div>
</div>
</li>
<?php
}
} ?>
</ol>
How to make that polls show for the guest, but when you click on the zf-answer-item, nothing happened?
Thanks!
I have a poll, the vote of which must be closed for guests.
<ol class="zf-structure-list zf-quiz_answer zf-text zf-clearfix">
<?php
if( isset( $question["answers"] ) ) {
foreach ($question["answers"] as $answer) {
?>
<li class="zf-answer-item <?php if (isset($_COOKIE["zf_poll_vote_ans_" . $answer["answer_id"]])) echo 'zf-selected'; ?>"
data-voted="<?php echo isset($poll_results["answers"][$answer["answer_id"]]) ? $poll_results["answers"][$answer["answer_id"]] : 0 ?>"
data-id="<?php echo $answer["answer_id"]; ?>" data-post-id="<?php the_ID() ?>"
data-group-id="<?php echo $question["question_id"]; ?>"
data-voted-group="<?php echo isset($zombify_poll_results["groups"][$question["question_id"]]) ? $zombify_poll_results["groups"][$question["question_id"]] : 0 ?>">
<div class="zf-answer js-zf-answer">
<div class="zf-checkbox-wrp"></div>
<div class="zf-poll-stat"></div>
<div class="zf-poll-stat_count"></div>
<div class="zf-answer_text">
<?php echo $answer["answer_text"]; ?>
</div>
</div>
</li>
<?php
}
} ?>
</ol>
How to make that polls show for the guest, but when you click on the zf-answer-item, nothing happened?
Thanks!
Share Improve this question edited Jan 2, 2019 at 17:55 Tom J Nowell♦ 61.2k7 gold badges79 silver badges150 bronze badges asked Jan 2, 2019 at 16:59 Grosso2020Grosso2020 1 1-
How are you implementing polls? I'm guessing based on the
data
attributes you're using a polls JS library, but you never mention which one, how it's added, how it runs, etc etc. Also where does this data come from? WP doesn't come with polls out of the box, are you using a custom plugin? Where does the$question
array come from? How do you determine what aguest
is? – Tom J Nowell ♦ Commented Jan 2, 2019 at 17:55
1 Answer
Reset to default 0You can check user logged in with is_user_logged_in
. This is a simple function to check user logged in or not. Can you try this?
<ol class="zf-structure-list zf-quiz_answer zf-text zf-clearfix">
<?php
if(is_user_logged_in()){
if( isset( $question["answers"] ) ) {
foreach ($question["answers"] as $answer) {
?>
<li class="zf-answer-item <?php if (isset($_COOKIE["zf_poll_vote_ans_" . $answer["answer_id"]])) echo 'zf-selected'; ?>"
data-voted="<?php echo isset($poll_results["answers"][$answer["answer_id"]]) ? $poll_results["answers"][$answer["answer_id"]] : 0 ?>"
data-id="<?php echo $answer["answer_id"]; ?>" data-post-id="<?php the_ID() ?>"
data-group-id="<?php echo $question["question_id"]; ?>"
data-voted-group="<?php echo isset($zombify_poll_results["groups"][$question["question_id"]]) ? $zombify_poll_results["groups"][$question["question_id"]] : 0 ?>">
<div class="zf-answer js-zf-answer">
<div class="zf-checkbox-wrp"></div>
<div class="zf-poll-stat"></div>
<div class="zf-poll-stat_count"></div>
<div class="zf-answer_text">
<?php echo $answer["answer_text"]; ?>
</div>
</div>
</li>
<?php
}
}
} else {
echo 'Please login to show these poll';
}?>
</ol>```
本文标签: phpHow to make a vote in the poll for registered users
版权声明:本文标题:php - How to make a vote in the poll for registered users? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745646677a2161066.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
data
attributes you're using a polls JS library, but you never mention which one, how it's added, how it runs, etc etc. Also where does this data come from? WP doesn't come with polls out of the box, are you using a custom plugin? Where does the$question
array come from? How do you determine what aguest
is? – Tom J Nowell ♦ Commented Jan 2, 2019 at 17:55