こんにちは、匿名ユーザーから投票結果を非表示にする方法はありますか?試験問題解決に関するフォーラムを作成しており、ユーザーが問題に対する回答を選択できるようにしたいと考えています。メンバーに他の人の回答を見るためだけに間違った回答をさせたくありませんが、匿名ユーザーにもそれを見られないようにしたいです。
「いいね!」 1
もう一つ、匿名からの返信を隠す方法を探してみましたが、何も見つかりませんでした。そのような機能は存在しますか?
こんにちは、解決しました。試したい方は、テーマコンポーネントを作成し、ヘッドに以下を追加してください。
<script type="text/discourse-plugin" version="0.8">api.onPageChange(() => {
if (!Discourse.User.current()) {
const pollContainers = document.querySelectorAll('.poll');
pollContainers.forEach(poll => {
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type === 'childList') {
const resultsButton = poll.querySelector('.toggle-results');
if (resultsButton) {
resultsButton.remove();
}
}
});
});
observer.observe(poll, { attributes: false, childList: true, subtree: true });
// Remove existing buttons if present
const existingButton = poll.querySelector('.toggle-results');
if (existingButton) {
existingButton.remove();
}
});
}
});
</script>
これにより、誰かが投票したときに「結果」ボタンが表示されるのを防ぐことができます。
「いいね!」 1
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.