1. If you update to Joomla 3.8.10, please make sure that you either do a full GitHub update of Fabrik, or disable caching for your lists (in the Advanced settings) or turn off Joomla's System Cache setting. A change in Joomla's cache code in 3.8.10 required a fix in Fabrik, which will be rolled in to the next release, but is currently only available in GitHub.
    Dismiss Notice
  2. We will be performing an update of XenForo (the forum software use on this site) this afternoon, Fri 8/17/2018. The forums will be unavailable for a (hopefully!) short time.
    Dismiss Notice

Change Yes/No element based on user access level

Discussion in 'Professional Support' started by keianrad, Sep 12, 2017.

Thread Status:
Not open for further replies.
  1. keianrad

    keianrad Member

    Level: Community
    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.
     
  2. troester

    troester Well-Known Member Staff Member

    Level: Standard
    Change (=set) on submit?
    You could use a php validation with 'replace' or a php plugin

    Gesendet von meinem GT-I9300 mit Tapatalk
     
  3. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Professional
    I'd go for the PHP plugin, although the validation would work.

    A PHP form plugin, running onBeforeProcess ...

    Code (Text):

    $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
     
    keianrad likes this.
Thread Status:
Not open for further replies.

Share This Page