Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Extending Userforms - tracking users, only allow one attempt


Reply


2 Posts   347 Views

Avatar
Futureweb

Community Member, 233 Posts

27 September 2011 at 11:49am

Hello,

I'm using the userforms module ( which is excellent! ) for a membership site. The concept is people create an account, log in, and get given a few questionaires/tests.

What I need is

> only allow a user to complete the form one time
> the site owners need to be able to find a client in the CMS and view the results of forms they've submitted

ideally it would be nice if I could extend the 'options' tab in the form to have 3 options:
> allow unlimited submissions | allow one submission | user can return and edit form

Any suggestins welcome

Thanks

Avatar
Futureweb

Community Member, 233 Posts

27 September 2011 at 12:33pm

Ok, i've got one part working by created this function in page.php

public function FormSubmittedAlready() {
      $MemberID = Member::currentUser()->ID;
      return DataObject::get('SubmittedForm', "`SubmittedByID` = '$MemberID' and `ParentID` = '$this->ID' ");      
}

and then putting this in page.ss

<% if FormSubmittedAlready %>
<p>You have already submitted this form</p>
<% else %>
   $Form
<% end_if %>

however, i had to remove $UserDefinedForm from the CMS field, to force the form to default to using the $Form area in the template. this means i've lost the abilty to control where the form is...

still looking for solutions to the other parts...