CoreFiles by mySites.guru
user.php41 lines, 736 bytes, from Joomla_4.2.0-Stable-Full_Package.zip
Raw History Compare with 4.1.5
md5
87f2bd313a538dcfe2148f0eaf56674a
sha1
c15c3ac22bdf6600e6b49bae1dccacd3411e2c59
sha256
f8fbb0ec2e7d9deed11b099bfb01ed6d730d2961768f3f052136f6d820b89c1c
<?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 = array();

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 16 releases, Joomla 4.2.0-beta3 to 4.3.0-alpha2. See them all, or every version of this file.