Frontend User Management

Frontend User Management, a forum discussion on Jojo CMS. Join us for more discussions on Frontend User Management on our General Discussion forum.

Back to Forum Index : Back to General Discussion   RSS
SoulGlo

30th May
Posts: 3

G'day,

I've been fiddling with JoJo for a few days now and I like what I see very much.

My question is: is there a way to dynamically show a user in the front page a login box if they are a guest, or if they are logged in as a registered user show something like 'Welcome User.'

I imagine I could pull a few things apart and put a few snippets in a template, but I am hoping there might be an easier way.

Cheers

SG

User Profile
Harvey

Lead Developer

Harvey

30th May
Posts: 190

Sure.

In your theme, add the following code to global.php (create one if it doesn't exist)
/* get user first name if logged in */
if (!empty($_USERID)) {
$data = Jojo::selectRow("SELECT us_firstname FROM {user} WHERE userid=?", $_USERID);
if (!empty($data['us_firstname'])) {
$smarty->assign('loggedinas', $user['us_firstname']);
}
}

Basically, this code checks to see if they are logged in. If they are, it queries the database for their firstname, and assigns the name to a Smarty variable.

Next, add this code anywhere in template.tpl (in your theme).
{if $loggedinas}
<p>Welcome back {$loggedinas}</p>
{else}
<p>Login form goes here (copy-paste from login page)</p>
{/if}

Hope this answers your question.
User Profile
SoulGlo

30th May
Posts: 3

Thanks Harvey. Works a treat.

To add a logout link - I've created a page that uses the logout plugin which I am linking to in an attempt to log the user out. But with no success.

Any ideas why?
User Profile
Harvey

Lead Developer

Harvey

30th May
Posts: 190

Jojo includes a logout page by default - It's located within the admin menu. You can drag it out of the admin menu and onto the main nav if you like, then all users can see it.

On the 'Navigation' tab, have a look at the permission settings - specifically view and edit permissions. You will want to make sure that only certain user groups can see the page, as there is no point showing a logout link to a user who isn't logged in.
User Profile
SoulGlo

30th May
Posts: 3

Interesting - that worked. Thanks again!
User Profile
Back to Forum Index : Back to General Discussion   RSS
You must be logged in to post a reply


You are not logged in
You need to Register or Log In before posting on these forums.