Forums

One time use?

m4niAc 13 Jan, 2012
I am needing some way to make a user only be able to use a form once, or until admin intervention.

Basically, a user would register for the website, and then have access to this form. Once they Submit the form, then they would have no more access to it unless there is admin intervention.


Any help is appreciated,
Thanks.
GreyHead 13 Jan, 2012
Hi m4niAc,

Save their user id to a table with a status flag. When they complete the form set the status to 1. Then in the Form HTML check the status, if it is 1 redirect them to another page, otherwise show the form.

Bob

PS Rather than use a table you could also use a Parameter in the User Object, it doesn't need an extra table but you of need to know how to set and get User Parameters.
m4niAc 14 Jan, 2012
Can you explain in more detail how to use the parameters and how I would do that please?

Thank you,
Brandon
GreyHead 14 Jan, 2012
Hi Brandon,

Very simply there are a couple of Joomla! User Object methods that you can use $user->getParam('key_name', 'default value'); and $user->setParam('key_name', 'value');

So if you define a new parameter 'status' you could set it with
<?php
$user =& JFactory::getUser();
$user->setParam('status', 1);
?>

and read it with
<?php
$user =& JFactory::getUser();
$status = $user->getParam('status', 0);
if ( $status ) {
  // do something . . .
}
?>

Bob

PS I wrote this up in more detail in a How-to for ChronoForms v3 that you can buy here
This topic is locked and no more replies can be posted.