Skip Navigation

[Resolved] How to disable checkbox field on user form for non admin users ?

This support ticket is created 5 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 3 replies, has 2 voices.

Last updated by paulineH 5 years, 4 months ago.

Assisted by: Nigel.

Author
Posts
#1351685
Capture d’écran 2019-09-30 à 14.59.04.png

Hello,

I created a custom checkbox field to display in a user form (to allow admin and site authenticated users to edit their profile) and i would like to insert a conditional display :

1. admin role only is able to check ou uncheck the box on users profile
2. if checked : front end display for users is not a checkbox (because i don't want other users to be able to check or uncheck) but a tick symbol.

I inserted this conditional field in my user form but on the front end users are still able to check or uncheck the box :

[wpv-conditional if="( NOT(empty($(adhesion-renouvelee))) )"] Adhésion renouvelée[/wpv-conditional]

How to add a conditional value for custom roles ?

#1351755

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Pauline

You can use Access to control the visibility of whole field groups (which could include just a single field), but that would only help either reveal or hide the field in your form, not to show something else in its place (i.e. the tick).

(For reference, that is described here: https://toolset.com/documentation/user-guides/access-control-for-user-fields/)

What you really need is to show the field on the form to users with certain roles, and show something else to other roles.

You can do that with the toolset_access shortcode, which is described here: https://toolset.com/documentation/user-guides/access-control-texts-inside-page-content/

Note that you will have to switch the form to expert mode if you haven't already.

Let me know how you get on.

#1354585
front-end-result.png
backend-user-edit.png

Hello,

I found the solution :

[types usermeta='my-checkbox-field' current_user='true' state="checked"]What i want to be displayed on the front-end if checkbox is checked.[/types] (and i did the same for "unchecked" box).

I better understand now how it works :
1. I created custom user fields to edit users profiles --> in the admin panel it displays the checkbox field that the admin user is able to check and uncheck.
2. I created a form with these fields I inserted in a front-end page to allow other users to edit their own profile. I used [types usermeta="my-checkbox-field" ... ] instead of [cred_field field="my-checkbox-field" ... ] to display the result of this field (that only the admin user is able to edit in the user edit admin panel).

thank you !

#1354603

My issue is resolved now. Thank you!