Quantcast
Channel: Joomla! Forum - community, help and support
Viewing all articles
Browse latest Browse all 1700

Administration Joomla! 5.x • Re: Insert User custom field in article text

$
0
0
This could be accomplished by embedding PHP code in the article and getting the user information within the PHP code.

Extensions such as Sourcerer (https://extensions.joomla.org/extension/sourcerer/) could be used for this purpose.

One of the advantages of Sourcerer is that it already creates the following variables ready for use (https://docs3.regularlabs.com/sourcerer ... g-php-code):
$app
The Joomla application framework
$document or $doc The html document
$database or $db The database
$user The user object containing the details of the guest or current logged in user
$Itemid The menu id of the page
$article The article object (only available when using the code inside articles)

I installed Sourcerer and created the following content:

Code:

<p>Hello {source}<?php    echo $user->name.',';?>{/source}</p><p>Welcome to the test site.</p>
Following is the result of this. Notice the logged in user name John Doe showing:
PHP_Code_Embed_test.jpg

Statistics: Posted by imanickam — Wed Aug 07, 2024 7:47 am



Viewing all articles
Browse latest Browse all 1700

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>