I think there are two ways to do this. These aren't complete solutions but maybe something you can use to get started or give an idea of what will work best for your situation:
1) write some code to interact with the FEU api
2) Use another module to record user activity
The FEU api can be used to get stuff and do stuff using a UDT to hold the code. Then execute the code using the CMS Event Manager when a specific module action happens to occur, or using FormBuilder's UDT options to fire the code when the form is submitted.
You would start by grabbing the FEU module into your code:
Code: Select all
$feu = cms_utils::get_module('FrontEndUsers');
and then you would probably do something for each user and would need to get their username or the feu id, for a logged in user:
Then if wanted, you could get the user's properties (for the currently logged in $uid):
Code: Select all
$properties = $feu->GetUserProperties($uid);
Need to loop through it, looking for your property and assign a var for the result:
Code: Select all
foreach($properties as $key=>$value) {
if ($value["vote"] == '1') {
$feu_voted = true
} else {
$feu_voted = false
}
From here, you would look at the FEU's module files for the correct API function needed. Maybe
SetUserProperty($title,$data) or SetUserPropertyFull($title,$data,$userid) and depending upon the current value of your property 'vote' and the action occurring on the frontend, you would set the 'vote' property to the desired value.
But, I've also use a module called, FEUChecklist to do something similar.
The client wanted to nag the FEU to update their password. Using FEUChecklist, a value can be set when a box is ticked. If the FEU didn't check that box, then conditional logic can be used to nag them.
In your case, you could tick checkbox (set the value using php) automatically for them when a vote is submitted.
Then, check for that value in your template(s).
The cool thing about using FEUChecklist is that all of the values recorded can be cleared by the admin. So, when it is time to vote again, clear the records allowing everyone to vote again.
Also, you can have more than one checklist item. If you have more than one voting category, or election period, you can have a checklist item to represent each of them.
The second cool thing is an admin can see who completed the item (who voted) and who didn't.
The only tricky thing is that the FEUChecklist checklist.tpl will have to be modified to find your checklist item and then set a var containing the value of that item. That way, you could use it in your template by capturing the module and then testing for the result of that var.
So, let's say in the checklist.tpl I set a var called "Voted" and it contains a value for the currently logged in person.
Then you could capture the whole module in your page template and then do stuff with the module's result data.
Code: Select all
{capture assign="VoteCheck"}{cms_module module='FEUChecklist'}{/capture}
{if $Voted == 'true} //stop them {else} // let them vote {/if}
Then you would need a UDT or some way to set the value of that FEUChecklist item when the person votes.