Skip to Content Skip to Menu

Autopopulate a field in RS Forms

  • mikebosh
  • mikebosh
  • OFFLINE
  • Posts: 9
  • Thanks: 0
  • Karma: 0
  • Add-ons
5 years 1 week ago #315221 by mikebosh
Autopopulate a field in RS Forms was created by mikebosh
Hi
Trying to autopopulate a field in RS Forms using following script
Works fine for most CB fields except email and name fields get following error
1054 Unknown column 'email' in 'field list'
Any help would be appreciated

//<code>
$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 `firstname` FROM `#__comprofiler` WHERE `user_id`='".$userId."'");
return $db->loadResult();
}
//</code>

Please Log in or Create an account to join the conversation.

  • Astrid
  • Astrid
  • OFFLINE
  • Posts: 183
  • Thanks: 68
  • Karma: 10
5 years 1 week ago #315223 by Astrid
Replied by Astrid on topic Autopopulate a field in RS Forms
Email and name should be called from user table:
Code:
//<code> $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(); } //</code>
Code:
//<code> $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 `name` FROM `#__users` WHERE `id`='".$userId."'"); return $db->loadResult(); } //</code>
The following user(s) said Thank You: nant, krileon

Please Log in or Create an account to join the conversation.

  • mikebosh
  • mikebosh
  • OFFLINE
  • Posts: 9
  • Thanks: 0
  • Karma: 0
  • Add-ons
5 years 1 week ago #315226 by mikebosh
Replied by mikebosh on topic Autopopulate a field in RS Forms
Astrid

Great thanks

BW
Mike

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum