[SOLVED]FEU User Properties - amending them?

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
quethiock
Forum Members
Forum Members
Posts: 42
Joined: Mon Jun 16, 2008 5:18 am

[SOLVED]FEU User Properties - amending them?

Post by quethiock »

Hi

I have a slight problem I am trying to overcome. I have to create an on-line voting form for recording votes from Members for proposed candidates to a charitable organisations committee. The Members will have to log-in to get to ther Protected Content pages to cast their votes. There will be a list of names and the Members can vote for a maximum number of those names (but not all of them). One of the things I am trying to implement is a method of preventing Members voting more than once!

Using CMS 1.11.9 (I know - I need to update it!) and FEU 1.8.6, FormBuilder 0.7.4, CustomContent 1.9.

I added a new property within FEU for each user called 'vote' as a check box and set to 'Null' when created.

Now what I am trying to do is to update the users 'vote' property to '1' after they press Submit in the voting form created in FormBuilder. I should then be able to check for that property in the web page template and tell them to 'go away - you have already voted' type of message. ;)

I've looked in the Help files for FEU and there are lots of references to reading the value of users FEU properties but nothing about writing to FEU properties, if in fact it can be done. I've tried various options to write but they were long shots that didn't work. ???

So, the question - is there a way to amend the value in a user's property in FEU from a script or have I gone about this problem the wrong way??

Any pointers/guidance would be much appreciated.

Mike
UK based
Last edited by quethiock on Wed Nov 05, 2014 10:00 am, edited 1 time in total.
JohnnyB
Dev Team Member
Dev Team Member
Posts: 731
Joined: Tue Nov 21, 2006 5:05 pm

Re: FEU User Properties - amending them?

Post by JohnnyB »

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:

Code: Select all

$uid = $params['id'];
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.
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
quethiock
Forum Members
Forum Members
Posts: 42
Joined: Mon Jun 16, 2008 5:18 am

Re: FEU User Properties - amending them?

Post by quethiock »

Wow!! What a comprehensive reply :D Thanks very much JohnnyB for that - I'm going to have to go away and study that carefully.

I can do the basic stuff and experiment with UDTs (I like them) and the Templates to get what I want but this problem with the FEU had me stumped. I had thought of Plan C (your suggestion is Plan B as my Plan A didn't work :( ). Plan C was to create a blank Text File and every time someone voted, open that file, write their membership number to the file, and then close the file such that every time the Voting page is called up, I can do a bit of PHP to check through the file for that Membership Number first and then allow the voting page to appear ... or not appear ... as appropriate.

Again, thanks for your response JohnnyB.

Regards

Mike
UK
Post Reply

Return to “Modules/Add-Ons”