An unusual requirement, if I may say so, but it can be done in a template override of the article view. Go to System - Templates - Site Templates and select your front end template, for example Cassiopeia Details and Files. Go to the tab Create Overrides and select Components - com_content. The override of the Article view of the Content component is now available as templates/cassiopeia/html/com_content/article/default.php.
The file default.php can now be modified without the changes getting overwritten in the next Joomla update. In the future the code may have to be refactored, depending on possible changes to the code of the article view.
The additions to default.php, shown below, check first the user groups of the author of the article and also the user group of the current user. If the article was created by a user in the Administrator or Super Users group, the article info will be hidden from all front end visitors and logged-in users. If the article info needs to be displayed to users in the Administrator and Super Users groups at the front end, uncomment the line marked 'optional' and comment out the previous line.
Insert the following lines after line 30 of the default.php override file in Joomla 4.2.9:
Code: Select all
// 20230322 author and current user
$Administrator = 7;
$SuperUsers = 8;
$author = Factory::getUser($this->item->created_by, 0);
// hide article info if author belongs to Administrator or Super Users groups
$hideInfo = in_array($Administrator, $author->groups) || in_array($SuperUsers, $author->groups);
// show article info if user belongs to Administrator or Super Users groups
$showInfo = in_array($Administrator, $user->groups) || in_array($SuperUsers, $user->groups);
// 20230322 end
Insert the following lines after the original line 51, as soon as the variable $useDefList has been set:
Code: Select all
<?php
// 20230322 start
$useDefList = $useDefList && !$hideInfo; // show info unless created by Administrators or Super Users
// $useDefList = (($useDefList && !$hideInfo) || $showInfo); // optional: show info to Administrator&Super User
// 20230322 end
?>