The code required to extract the first name of the currently logged in user is fairly simple. Here's an example:
<?php
$user = JFactory::getUser();
if (!$user->guest) {
echo strtok($user->name, ' ');
}
?>
Using the free or paid version of Sourcerer you could insert the code directly into an article as follows:
{source}<?php $user = JFactory::getUser(); if (!$user->guest) {echo strtok($user->name, ' ');} ?>{/source}
For a more elegant solution, create a Custom HTML Module using the above code with Sourcerer like this:
{source}
<?php
$user = JFactory::getUser();
if (!$user->guest) {
echo strtok($user->name, ' ');
}
?>
{/source}
Specify a custom module position e.g. firstname
and remember to set Prepare Content = Yes under the Options tab. Save and Close the module.
Inserting the first name of the currently logged in user into content can then be done more simply using: {loadposition firstname}