Email validation only for special group user

Status
Not open for further replies.

keianrad

Member
I need to run the validation plugin for some special user groups.
There is a user element in the form and I tried to use the code that listed below but it doesn't work. I know that this code is not supposed to do that but I just tried that.

Would you please help me for that, Thanks:

Code:
return '{app_assessment___created_by}' == {$my->id};
 
So what you are saying is you want to run validation on a field only when a particular user is logged in? Is that correct?
Are you putting this code in the condition tab of the validation?
 
The example you gave, and your title/description, don't seem to match.

If you want to find out if the current user is a member of a specific group:

Code:
// will return  true if user is in group 123
$myUser = JFactory::getUser();
$myGroups = $myUser->getAuthorisedGroups();
return in_array(123, $myGroups); // replace 123 with the id of the group

You can do the same thing for view levels, using getAuthorisedViewLevels() instead. Which would probably be the way to go, if you need to test for "some special user groups" (rather than a single group). Put those groups into a view level, and do ...

Code:
// will return true if user has access level 123
$myUser = JFactory::getUser();
$myLevels = $myUser->getAuthorisedViewLevels();
return in_array(123, $myLevels); // replace 123 with the id of the view level

-- hugh
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top