Remember me

default value from database for signed in user

6 years 8 months ago #1

  • Stuart's Avatar
  • Stuart
  • Posts: 114
Hi
In another form product we are able to set the default user details if the user is signed in, simply by adding the code in the form field default value
The code is simple and works like this
________________________________

$user = JFactory::getUser();
$db = JFactory::getDbo();
$userId = $user->get('id');

// Is the user logged in?
if ($userId) {
// Grab the value from the database.
$db->setQuery("SELECT `email` FROM `#__users` WHERE `id`='".$userId."'");
return $db->loadResult();
}
________________________________
this saves an existing user form having to fill in a number fields and means that if the user is not an exsiting one then we have the one form that handles both easily

Is there a similar syntax / capability in balbooa forms?

Thanks in advance
Stuart

6 years 8 months ago #2

  • Artem's Avatar
  • Artem
  • Posts: 11342
Hello Stuart,

Thank you for contacting us!
I'm sorry, but similar things are not available in the Forms component

Many thanks,
Artem

6 years 8 months ago #3

  • Stuart's Avatar
  • Stuart
  • Posts: 114
Thanks for the feedback
It is nice for the user to see a form pre populated with their details so i might create a set of two forms one if signed in and one if not and then add some custom code around the signed in form to pull out the data and display
bit of a workaround though - is it a feature that is likely to make it on to the future roadmap at all?
Thanks
Stuart
Powered by Kunena Forum