Change Yes/No element based on user access level

Status
Not open for further replies.

keianrad

Member
There is a Yes/No element in a form in a hidden group. I need to change the value based on the user access level of user who is submitting the form.

I need to be "No" for registered level and be "Yes" for Special level.

Is it possible?
Thank you for your help.
 
Change (=set) on submit?
You could use a php validation with 'replace' or a php plugin

Gesendet von meinem GT-I9300 mit Tapatalk
 
I'd go for the PHP plugin, although the validation would work.

A PHP form plugin, running onBeforeProcess ...

Code:
$myLevels = JFactory::getUser()->getAuthorisedViewLevels();
if (in_array(3, $myLevels)) {
   $formModel->updateFormData('yourtable___yesno', '1', true);
}
else {
   $formModel->updateFormData('yourtable___yesno', '0', true);
}

Change yourtable___yesno to your full element name.

NOTE - this sets to Yes if Special, and No if not Special. You said to set to Yes if Special and No if Registered ... but that doesn't handle cases where the user is neither, or both.

So I'm not sure what you want to do if they are neither or both, but I'm assuming your logic should really be as I've written it. Set to Yes if Special, otherwise No.

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

Thank you.

Members online

Back
Top