Recent Topics

1 Dec 08, 2006 17:25    

Quick question and probably a simple one for experts here.

At the moment I show the number of words in a post and the number of views it has received.

Is it possible to make showing this conditional on a user being logged in. So regular visitors wouldn't see the information but logged-in users would.

I'm assuming this is a case of some simple php "if" command. But I'm no php coder hence asking for help.

Although at first I plan on using this for a simple thing, the idea is to learn the methodology and then I can use it for more elaborate features.

Thanks for reading.

H

2 Dec 08, 2006 18:31

urm, this is off the top of my head, but you should be able to change lines that look remotely close to this :-

<?php $Item->views ?>

to look like :

<?php if( is_logged_in() ) $Item->views ?>

¥

3 Dec 08, 2006 18:40

Thanks I'll try that.

4 Dec 08, 2006 22:31

It worked great thanks. Is there something similar to check not logged in?

5 Dec 09, 2006 01:37


if( ! is_logged_in() )
{
  echo 'not logged in.. :-)';
}

6 Dec 09, 2006 01:45

Thanks, just as you posted that I'd solved it myself. I've now got my site set up so that it only shows Google Adverts if a user isn't logged in.

So now my registered users have the benefit of no advertising.

Not that I make much anyway. :)

7 Dec 09, 2006 02:01

..and now even less.. ;)

Hooray for ad-free sites.. ;)


Form is loading...