Run from php plugin for sepcial user groups

keianrad

Member
I need to run this code for some special user groups in a form php plugin. how can I do that?

Code:
$studyProject = new StudyProject(3);
$studyProject->createSingleTask($formModel, 'app_documents');
$studyProject->createProject($formModel, 'app_documents');

Thank you for your help.
 
The usual way to do that would be to create a view level in J! which contains the groups you want, and then use getAuthorisedViewLevels for the logged on user, and check that the ID of your view level is in that array:

Code:
$user = JFactory::getUser();
$levels = $user->getAuthorizedViewLevels();
if (in_array(123, $levels)) {
   // ... your code here ...
}

Replace 123 with your view level ID.

-- hugh
 
Thank you hugh. I used the code but it doesn't work. I get this error:
Call to undefined method JUser::getAuthorizedViewLevels()

Code:
$user = JFactory::getUser();
$levels = $user->getAuthorizedViewLevels();
if (in_array(11, $levels)) {
$studyProject = new StudyProject(3);
$studyProject->createSingleTask($formModel, 'app_documents');
$studyProject->createProject($formModel, 'app_documents');

}
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top