Documentation

IsUserVoted

IsUserVoted (VOTE_ID)

The function returns true if a user had already took part in the poll and is not permitted to vote again or false otherwise.

Parameters

ParameterDescription
VOTE_IDPoll ID.

Example

The following is the example of the file vote_now.php used in the public section.

<?
// Display a form with the current poll of a channel if a user did not vote yet.
// If a user did, redirect to a page with the results of the current poll
require_once(
    $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
if (CModule::IncludeModule("vote"))
{
    $VID = GetCurrentVote("SURVEY");
    if ($VOTING_OK=="Y" || IsUserVoted($VID))
        $ALREADY_VOTED = "Y";
    else 
        $ALREADY_VOTED = "N";
}

if (strlen($APPLICATION->GetTitle())<=0)
    $APPLICATION->SetTitle(GetMessage("VOTE_VOTING_TITLE"));

require_once(
    $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_after.php");
?><?
if (CModule::IncludeModule("vote")) 
{
    if ($ALREADY_VOTED == "Y")
        ShowVoteResults($VID); else ShowVote($VID);
}
require_once(
    $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog.php");
?>
© «Bitrix24», 2001-2024
Up