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

30 May 2008
Posts: 17

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

Harvey

Core Developer

Harvey

30 May 2008
Posts: 327

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.
SoulGlo

30 May 2008
Posts: 17

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?
Harvey

Core Developer

Harvey

30 May 2008
Posts: 327

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.
SoulGlo

30 May 2008
Posts: 17

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



You need to Register or Log In before posting on these forums.