1

So any profile data filled in within a user profile for joomla is being saved with quotes around it in the database. Does anyone know how to remove the quotes? It seems to do it even as the default value. Field type is set to TEXT.

sample database

2 Answers 2

3

As far as I can tell from the profiles plugin code, the speech marks come from data being JSON encoded before being entered into the database.

$tuples = array();
                $order = 1;

                foreach ($data['profile'] as $k => $v)
                {
                    $tuples[] = '(' . $userId . ', ' . $db->quote('profile.' . $k) . ', ' . $db->quote(json_encode($v)) . ', ' . ($order++) . ')';
                }

                $db->setQuery('INSERT INTO #__user_profiles VALUES ' . implode(', ', $tuples));
                $db->execute();

Pretty sure that to remove them you'd need to edit core Joomla files, which you should never do.

1

The profile_value field is a JSON encoded field, when it's empty it will be an empty quoted string as the default value.

You don't want to mess with the way the data is stored. (unless you want to write your own version of the profile plugin)

What You will need to do is parse the JSON data in your code to get to the underlying values.

This is common in many places in Joomla and other CMS systems. For example, the params field in almost every Joomla component is also a JSON encoded field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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