[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/plugins/fields/user/tmpl/ -> user.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Plugin
   5   * @subpackage  Fields.User
   6   *
   7   * @copyright   (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  defined('_JEXEC') or die;
  12  
  13  use Joomla\CMS\Factory;
  14  
  15  $value = $field->value;
  16  
  17  if ($value == '') {
  18      return;
  19  }
  20  
  21  $value = (array) $value;
  22  $texts = array();
  23  
  24  foreach ($value as $userId) {
  25      if (!$userId) {
  26          continue;
  27      }
  28  
  29      $user = Factory::getUser($userId);
  30  
  31      if ($user) {
  32          // Use the Username
  33          $texts[] = $user->name;
  34          continue;
  35      }
  36  
  37      // Fallback and add the User ID if we get no JUser Object
  38      $texts[] = $userId;
  39  }
  40  
  41  echo htmlentities(implode(', ', $texts));


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer