(SOLVED) How to restrict access to form (CF 4 / J1.6)

josej 12 Aug, 2011
I am using Chronoforms_J1.6_V4_RC1.9 and Joomla 1.6.4

I need to restrict access to a registration form so only unregistered users will see it.

I've read other posts here that suggested I add the following code to the form:

<?php
$user =& JFactory::getUser();
echo $user->get('id');
if($user->get('id') > 0){return;}
?>


I added it to a Custom Code action - it is the first one executed On Load. I know I am getting the correct id because it outputs it (echo $user->get('id');).

In the Custom Code settings I chose Mode: View. I also tried running it on Mode:Controller without success.

Even when I delete everything and leave only the return; command (see below) it still doesn't work.

<?php
return;
?>


It seems that whatever I do the form always show.

By the way I am loading the form inside an article using {chronoforms}FormName{/chronoforms} in case it makes any difference.

Thank you for reading!

EDIT: just tried running the form as a module from a menu item and it still does not restrict access. It shows the form to everybody. Thanks.
Max_admin 13 Aug, 2011
Hi jose,

Try to add an "Authenticator" action (under the security actions group) to your form and configure it to whatever groups you want the form to be accessible for.

regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
josej 13 Aug, 2011
1 Likes

Hi jose,

Try to add an "Authenticator" action (under the security actions group) to your form and configure it to whatever groups you want the form to be accessible for.

regards,
Max



Hi Max,

Thank you for the quick response. The Authenticator does work.

One quick tip to help future readers. Do not forget to add the Show Stopper action (under the Core Actions group) in the Denied event of the Authenticator.

Basically the Authenticator checks if the user should have access to the form. If not, it will execute the action inside the Denied event. If you don't put the Show Stopper there, the form will show even for users that should not have access.

Thank you again for responding.
rangrage 29 Jul, 2012
Hi guys,

I am still having a problem with this. I have added the authenticator, and also added the Stop Show in the deny action but for some reason it just does not work for me.

Any suggestions will be greatly appreciated.

Thanks for your help.
GreyHead 29 Jul, 2012
Hi rangrage,

What settings do you have in the Authenticator?

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