3

When using the TinyMCE editor, how can I display the username at the top of an article?

1
  • 1
    You don't mean you want to display the article's Author's name, right?
    – FFrewin
    Commented Aug 20, 2015 at 20:26

4 Answers 4

4

You can't display dynamic data this way through an article by default, as the editors won't process php.

However, to your rescue, there are plugins for this.

You can install Regular Lab's Sourcerer Plugin, and now you can write php, or other code directly in your articles.

It even supports some of the most common Joomla variables and Objects, which are ready to use. JUser is one of these, so all you need to display user data is a code inside your article like below:

{source}
<?php echo $user->username; ?>
{/source}

For more info about User Profile see: How to display user profile information?

The other way to display dynamic date in your article is to modify the article's template with an override and put all your php code in there.

Joomla Template/Layout Overrides Links

2

Download, install and enable a plugin name DirectPHP. This plugin gives the facility to write PHP code in article. After these in your article write following code.

<?php 
   jimport( 'joomla.user.helper' ); 
   $user = JFactory::getUser();
   echo $user->username;
?>
1
  • 1
    How would you call a custom field
    – Eoin
    Commented Mar 20, 2020 at 22:57
1

If you want to see the author on your website you have to change the settings of the article. System > Global Configuration > Articles and go to tab: "Articles" and look for "Show Author" and activate it.

0

The following extension might help adding user field values to content: https://extensions.joomla.org/extension/edition/user-field-values-in-articles/ .

This extension basically allows you to add user field values to content in Joomla! via a editor button or using placeholders. Some custom field types I see are also supported.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.