Hi There,
I have a site which uses chronoforms to submit ads. I would like to find out if there is a way to only allow a user to open a form if he is logged in as a registered user. This needs to be on a per form level as some forms do not require the user to be logged in.
I assumed that the watchman plugin would do the trick, but I cannot seem to get it to work as expected. With the plugin enabled, not matter what I do, it redirects to the homepage of the website instead of the form.
Thanks,
Steven
I have a site which uses chronoforms to submit ads. I would like to find out if there is a way to only allow a user to open a form if he is logged in as a registered user. This needs to be on a per form level as some forms do not require the user to be logged in.
I assumed that the watchman plugin would do the trick, but I cannot seem to get it to work as expected. With the plugin enabled, not matter what I do, it redirects to the homepage of the website instead of the form.
Thanks,
Steven
Hi Steven,
I think there's been a few threads with similar issues not so long ago.
Roughly though, you'll want to add a piece of code like below to your form code to prevent it from showing:
Further, to prevent anonymous visitors from submitting data, regardless of the form not showing, add this to the serverside validation code (and remember to enable the serverside validation):
/Fredrik
I think there's been a few threads with similar issues not so long ago.
Roughly though, you'll want to add a piece of code like below to your form code to prevent it from showing:
<?
$user =& JFactory::getUser();
if ($user->gid == 0) {
echo "You are not authorized to view this page!<br />Please logon.";
return;
}
?>
Further, to prevent anonymous visitors from submitting data, regardless of the form not showing, add this to the serverside validation code (and remember to enable the serverside validation):
<?
$user =& JFactory::getUser();
if ($user->gid == 0) {
return "You are not authorized to view this page!";
}
?>
/Fredrik
Thanks, it worked like a charm!
This topic is locked and no more replies can be posted.