CoreFiles by mySites.guru
user.php41 lines, 731 bytes, from Joomla_4.4.2-Stable-Full_Package.zip
Raw History Compare with 4.4.1
md5
5fe57cf88686eb3335ce63ec3b1c9975
sha1
9317c6afab4cf68c7cbd89e18c1ff6bc71186cf2
sha256
cb61ac8ed7d0f03cb51a51a39a8e739791c5ed3a112407e2917dc0ae435db5b1
<?php

/**
 * @package     Joomla.Plugin
 * @subpackage  Fields.User
 *
 * @copyright   (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

use Joomla\CMS\Factory;

$value = $field->value;

if ($value == '') {
    return;
}

$value = (array) $value;
$texts = [];

foreach ($value as $userId) {
    if (!$userId) {
        continue;
    }

    $user = Factory::getUser($userId);

    if ($user) {
        // Use the Username
        $texts[] = $user->name;
        continue;
    }

    // Fallback and add the User ID if we get no JUser Object
    $texts[] = $userId;
}

echo htmlentities(implode(', ', $texts));

The same content is in 60 releases, Joomla 4.2.7-rc1 to 5.0.0-alpha1. See them all, or every version of this file.