How to get user id?

How to get the current user ID in a ChronoForms form.

Overview

The user needs to capture the logged-in user's ID to store it with form data in the database.
Use a hidden field in the form and populate it with the user ID via custom PHP code in the form's Setup - on load action.

Answered
ca calangoloco 03 Dec, 2014
Hi,

I have form to send data to database (text box and textarea box). It work. But I don't know how get user id to send to database. Anyone can help-me?

Thanks in advance.
ca calculus00 03 Dec, 2014
ca calangoloco 03 Dec, 2014
Answer
I was like this:

Hidden field with field name equal to the field

In Setup - on load: Custom code:

<?php
$user =& JFactory::getUser();
$form->data['client_id'] = $user->id;
?>
This topic is locked and no more replies can be posted.