Only allowing registered users to use form

sighani 02 Dec, 2008
HI There

I was wondering if there is a way of ONLY allowing registered users to use the form? I'm using Joomla 1.5.6

Background:

I have an Ask a Psychic feature on my website. Where a user clicks on an image linking to the form. But I only want the form to be available for registered users only.

Can anyone help?

ChronoForm is great by the way! Works real well.

Cheers
Shelby
GreyHead 02 Dec, 2008
Hi sighani,

Yes you can - you need to look up the user_id in the User object - if it's 0 then the user is either a guest or not logged in.

You can access the user object with this code in your form html
<?php
$user = JFactory::getUser();
if ( $user->id == 0 ) {
  // this is a guest . . .
} else {
  //this is a logged in registered user
}
?>

Bob
sighani 02 Dec, 2008
Hi Bob

Thanks for that. It's a bit over my head though as I don't know much about php. I did put the code in the form html.

I tested out the form and it still allows non registered users to use the form.

I may have missed something here?
GreyHead 02 Dec, 2008
Hi sighani,

Yes, you need to add your form code or other messages in where I left comments.

You will need a little knowledge of php & html to get this to work correctly, it really isn't practical for Max or I to code everyone's forms for them in full detail.

Bob
sighani 02 Dec, 2008
Hi there

Thanks for your time anyways.🙂

But I have found a way to work this.

I created this as a menu and set the access level to Registered only.

Love the app!


Cheers
Shelby
This topic is locked and no more replies can be posted.