[solved] how can I restrict my Component?

_domk
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Sun Aug 10, 2008 1:21 pm

[solved] how can I restrict my Component?

Postby _domk » Sun Aug 10, 2008 5:41 pm

Hi everyone,

I have written a Component to write data into a database table.

How can I achieve, that only registered users can launch that component??

Thanks in advance...

Dominik
Last edited by _domk on Fri Aug 15, 2008 11:01 am, edited 1 time in total.

Gergo Erdosi
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4031
Joined: Sat Nov 11, 2006 9:34 pm
Location: Hungary

Re: how can I restrict my Component?

Postby Gergo Erdosi » Wed Aug 13, 2008 6:32 pm

Welcome to the forum!

At the beginning of the code use something similar like this:

Code: Select all

$user =& JFactory::getUser();
if ( $user->guest ) {
  echo( 'You need to log in to use this component' );
  return false;
} else {
  return true;
}

_domk
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Sun Aug 10, 2008 1:21 pm

Re: [solved] how can I restrict my Component?

Postby _domk » Fri Aug 15, 2008 11:02 am

Thank You very much.

Works like a charm now.

Dominik

Gergo Erdosi
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4031
Joined: Sat Nov 11, 2006 9:34 pm
Location: Hungary

Re: [solved] how can I restrict my Component?

Postby Gergo Erdosi » Fri Aug 15, 2008 11:15 am

No problem. :) However the code I wrote is not the best, first I wanted to write a function, that's why I included the return true and false values, but with the simple if statement there is no need to have return values.


Return to “Joombie Coding Q/A”

Who is online

Users browsing this forum: No registered users and 3 guests