• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Save form submission date to CB field

Save form submission date to CB field 2 months 4 days ago #43847

I need to save the date the form was submitted to a cb field to displayon a users profile. I've had a go with the code in the scripting section but it just crashes out. Any suggestions?

CB field : cb_upgradeapplied
RS Form field : Date

The demo script. I just changed the two fields as shown.

// Get a database connection
$db = Joomla\CMS\Factory::getDBO();
// Get the current logged-in user's data
$user = Joomla\CMS\Factory::getUser();

// Setup the query
$db->setQuery("UPDATE #__comprofiler SET cb_upgradeapplied = '".$db->escape($_POST)."' WHERE user_id = '".$db->escape($user->id)."'");
// Execute it.
$db->query();
The administrator has disabled public write access.

Save form submission date to CB field 2 months 3 days ago #43848

I'm now trying this code from the Mappings section wizard which also doesn't work.

INSERT INTO `xxx_comprofiler` (`user_id`,`cb_upgradeinformation`) VALUES ('{global:userid}','{Upgrade_information:value}')

I need to post the data from the Upgrade_information:value field into the cb_upgradeinformation for the current logged in user.
The administrator has disabled public write access.

Save form submission date to CB field 2 months 2 days ago #43850

  • iceferret
  • iceferret's Avatar
  • OFFLINE
  • Gold Boarder
  • Posts: 245
  • Thank you received: 64
No guarantees as I can't test this not having CB but try
// Get a database connection
$db = Joomla\CMS\Factory::getDbo();
// Get the current logged-in user's data
$user = Joomla\CMS\Factory::getUser();
 
// Define the RSForm!Pro field name for the Date field
$formFieldName = 'Date'; // Change this to match the RSForm field name exactly
 
// Retrieve the RSForm!Pro Date field value safely
$submittedDate = Joomla\CMS\Factory::getApplication()->input->post->getString($formFieldName, '');
 
// Convert the date to a valid MySQL format if needed (YYYY-MM-DD)
if (!empty($submittedDate)) {
    $dateObject = DateTime::createFromFormat('d/m/Y', $submittedDate); // Adjust format as per RSForm!Pro output
    if ($dateObject) {
        $submittedDate = $dateObject->format('Y-m-d'); // Convert to MySQL format (YYYY-MM-DD)
    }
}
 
// Ensure we have a valid user and a valid date
if ($user->id && !empty($submittedDate)) {
    // Prepare the query
    $query = $db->getQuery(true)
        ->update($db->quoteName('#__comprofiler'))
        ->set($db->quoteName('cb_upgradeapplied') . ' = ' . $db->quote($submittedDate))
        ->where($db->quoteName('user_id') . ' = ' . (int) $user->id);
 
    // Execute the query
    $db->setQuery($query);
    $db->execute();
}
 

Just be sure to check your RSForm!Pro Date Format – If the date format is different, update d/m/Y in DateTime::createFromFormat().
Make Sure "Date" is the Correct Field Name – RSForm!Pro is case-sensitive, so ensure it matches exactly.
If you can keep your head when all about you are losing theirs, then you obviously don't understand the situation!
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!