3

I have a public registration form process which assigns a specific group/permissions 'eventeer' to a user. This user can then login and can enter/edit information in a 'shared' section. 'Shared' meaning both admins + eventeer groups use the same admin cp section form.

Issue: I have one field that I dont want to expose to an 'eventeer' but only expose for admin. Can this be accomplished with craft v2.6+ and/or plugin?

Thanks in advance.

2

Not natively, but there's the Control Panel Body Classes plugin, which would enable you to add the handle for your "eventeers" User Group as a CSS classname to the <body> tag (i.e. body.usergroup-eventeers, if "eventeers" is the handle for your User Group).

With that classname in place, you could add some CSS to the Control Panel (easiest done w/ the CPCSS plugin) to hide the particular field, e.g. w/ something like the following:

body.usergroup-eventeers #fields-yourFieldHandle-field {
    display: none;
}

...or, if it makes sense, you could flip it around and have your field hidden by default, and visible only if the <body> has the .userlevel-admin classname - which would in effect hide the field from everybody except people w/ admin accounts:

#fields-yourFieldHandle-field {
    display: none;
}

body.userlevel-admin #fields-yourFieldHandle-field {
    display: block;
}

(Obviously, you'll need to change the yourFieldHandle part for the field's selector to your field's actual handle.)

In any case, keep in mind that this will not be a secure solution in the sense that the field will still be there, and any tech-savvy "eventeer" user can easily make the field appear by removing the above CSS rule in their browser's dev tools. However, in the current iteration of Craft it's as close as you'll come to accomplish what you want.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.