CoreFiles by mySites.guru
user.php40 lines, 787 bytes, from Joomla_6.0.2-Stable-Full_Package.zip
Raw History Compare with 6.0.1
md5
5306ee21533cfa25f5027b972cc4efa5
sha1
94fe2a48e73c0d31da0c01bc9bf9421956184a0a
sha256
099afa92aae48e0185d7fc3ff05ac0d37d00a11bf60f9e26c14fc15295819889
<?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;

/** @var \Joomla\Plugin\Fields\User\Extension\User $this */
$value = $field->value;

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

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

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

    $user = $this->getUserFactory()->loadUserById($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 50 releases, Joomla 6.0.0-alpha1 to 6.2.1-rc1. See them all, or every version of this file.