Forums

Populate custom code with username on submit

mirkob 18 Mar, 2014
Hello,
i am using Chronoforms v4 for my fishing club and up until now I used it only for contact form.

Now i want to create an application form for events, but unfortunately i have no clue how to get started.
Basically, it should be a simple form with three fields:
“Event description”, “Register” (Submit) button, and a “Registered users” field where the already registered members are listed (I think some kind of custom code field)
Now, when the user click on “Register” button, his username should appear and stay in the “Registered users” field (below the other usernames which already are registered).

I know how to read the username field from Joomla:
<?php
// Get user-information from Joomla
$user = &JFactory::getUser();
?>

But how can i inject the username into the “Registered users” field?

Thank you in advance!
GreyHead 19 Mar, 2014
Hi mirkob,

Is this for users to register themselves? If so then I'd make the form available to logged in users only (use the Authenticator action in the On Load event). When the form is submitted get the user's name with a Custom Code action:
<?php
// Get user-information from Joomla
$user = &JFactory::getUser();
$form->data['user_name'] = $user->name;
?>
then save the data to a registration table including a user_name column.

Now when the form is loaded you can use a DB Multi-Record Loader to read the registration table, get the list of registered names and show that under your Registration button.

This sounds complicated but it isn't too bad. Take it one step at a time and all will be well.

Bob
mirkob 19 Mar, 2014
Hey GreyHead,
thank you so much for the fast answer.
i will try this out.
Best regards!
mirkob 20 Mar, 2014
Hello GreyHead,
the form is working just fine, thanks!
But there is one more thing...
Most of the users are clicking twice or three times on the "submit".
Is it possible to set an option in the "data displayer" part of the "DB Multi Record Loader" to grout the entries by name (to have a list with unique names displayed)?
I have already tried the "Group model data" option (under "Advanced") but that's not working.
is there a field where i can add the "group by user_name" option?
GreyHead 23 Mar, 2014
Hi mirkob,

I'd suggest that you try my Anti Flood [GH] action.

Bob
mirkob 23 Mar, 2014
Hi Bob,
that will fit, Thanks!
Mirko
This topic is locked and no more replies can be posted.