Display Form only for specific user group

Moh-Aw 23 Jul, 2015
Hello,

I'm trying to display a form inside an article only for a specific user group. I currently came up with these two alternatives on how to display the form:

1. I could use the {chronoforms} tags inside the article. I don't see an option to restrict the access in the form editor though. Is there a way?

2. I could use php inside the article. My code currently looks like this:

<?php
// no direct access
defined('_JEXEC') or die('Restricted access');
$user =  JFactory::getUser();
$groups = JUserHelper::getUserGroups($user->id);

if(in_array(10, $groups)){
	
    // SHOW FORM HERE


} elseif(in_array(11, $groups)) {
	$output .= "<a style='float:right;' onclick='return confirm(\"Do you really want to leave your clan?\");' href='components/com_joodb/plugins/leave.php'><img src='images/exit.png' align='center' border='10' alt=''>  Leave Clan...</a>";
}
?>


I found the following code snippet in this link https://www.chronoengine.com/forums/posts/f2/t99179.html

jimport('cegcore.joomla_gcloader');
ob_start();
$output = new JoomlaGCLoader('front', 'chronoforms5', 'chronoforms', array("chronoform" => "FORM_NAME"), array('controller' => '', 'action' => ''));
$return = ob_get_clean();
echo $return;


But just like the user in that other thread I am getting just a blank page. Can you help me solve this?
GreyHead 23 Jul, 2015
Answer
Hi Moh-Aw,

Please try using an Authenticator action from the Security Actions Group in the form On Load event.

In the On Success event add the HTML (Render form) action and in the On Fail event add a Display Message action.

Not tested but I think that should work OK. Setting the Group permissions can be tricky - Max has written a bit about it in this ChronoForums FAQ.


Bob
Moh-Aw 24 Jul, 2015
Yes, that worked.

Note: All parent user groups have to be set to 'not set'.
Sten 30 Nov, 2015
Hi GreyHead,
Hi Max,

Thanks a lot for Chonoforms !

I'm tryng to use Athentificator with parameters like Max offers here : http://www.chronoengine.com/component/chronoforums/posts/f2/t95208.html

Unfortunately that doesn't work : if I put "no set" to Public, everybody can access the form.

If I put "denied", nobody can read it even super users.

I don't understand.
Please help me !

Sten
GreyHead 02 Dec, 2015
Hi Sten,

Please set Public to 'Allowed' - Public here is not really Public, it is the root User Group and if that is Not Set or Denied then all other groups are as well.

To block Guests set Guest to Denied, then other groups as needed - but check in the User Group tree - if you set a Group to Denied, then all sub groups will be Denied as well.

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