Development

Populate RS forms with user custom fields

Populate RS forms with user custom fields

If you need a subscriptionform with prefilled custom field values, and you are using RS Forms, do the following

Go to your form, use a text box, and add a default value like this

//<code>
use Joomla\CMS\Factory;
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
$customFields = FieldsHelper::getFields('com_users.user', JFactory::getUser(), true); 
return $customFields[3]->value;
//</code>

 

This will populate the field with the value of custom-field with ID 3. You can do this as much as you like.

Happy coding!

This article provides a basic example of populating RS Forms with custom user data. However, there are several important considerations and potential improvements to make this more robust and user-friendly.

Stuck on something else?

Doctor Joomla is a project of Cloudfaction, a Dutch agency building and maintaining Joomla sites since 1999. The articles are made with the help of AI, so tell us if something does not match your screen. Mail info@cloudfaction.nl if you want someone to look at yours.

Rather have someone look at it

Doctor Joomla is a Cloudfaction project.

A Dutch agency that has been building and running Joomla sites since 1999. If your site needs more than an article can fix, get in touch.