0

I have Joomla 3.8.11 and RSFORM 2.0.14.

I want to update the Community Builder fields of the logged-in user.

The main fields that I am trying to update are via some checkboxes: enter image description here

The checkbox field from RSFORM has exactly the same values that the checkbox fields from Community Builder have. enter image description here

enter image description here

I tried this method: https://www.rsjoomla.com/support/documentation/rsform-pro/custom-scripting/update-a-field-from-community-builder.html

And this method: https://www.rsjoomla.com/blog/view/314-rsformpro-user-profile-community-builder-and-mappings.html

But it doesn't work. When I go to see the profile, I don't see the fields updated and there is no error message.

Here is the code that I added in php option "Script called on form process":

$db = JFactory::getDBO();
$user = JFactory::getUser();
$db->setQuery("UPDATE njhggy_comprofiler SET cb_skills = '".$db->escape($_POST['form']['skills'])."' WHERE user_id = '".$db->escape($user->id)."'");
$db->query();

Does anyone know what I am doing wrong?

1

There may or may not be addition issues with your attempt, but I can tell at first glance that you are not executing your UPDATE query.

https://docs.joomla.org/Inserting,_Updating_and_Removing_data_using_JDatabase#Updating_a_Record

$db = JFactory::getDBO();
$user = JFactory::getUser();
$db->setQuery("UPDATE #__comprofiler SET cb_skills = " . $db->q($_POST['form']['skills']) . " WHERE user_id = " . (int)$user->id);
$db->execute();

or with an object:

$object = (object)['user_id' => JFactory::getUser()->id, 'cb_skills' => $_POST['form']['skills']];
JFactory::getDBO()->updateObject('#__comprofiler', $object, 'user_id');
  • 1
    @Cff you have been online since I posted my answer. Did my answer resolve your issue? If so, do you know how to accept my answer (to stop the system from bumping this page)? If not resolved, do you have any feedback that will assist volunteers in helping you further? – mickmackusa Jun 28 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.