I have an update user form where the user will be able to update his details.
I have radio button for user status. (approve ,reject) and i have organization field . I would like to make the organization field readonly only if the radio button checked to rejected
thank you, Jamal. I will contact you once I set up the form.
Awesome. Thank you!
I'll set this ticket as waiting for your reply until you prepare the form.
I have created the form. and I have created 2 users both with 12345 password. One approved and the other one is rejected.
The organization should be readonly for the approved person and active for the rejected one.
Log in using these account and access the page
hidden link
My apologies for the late reply, but I do not work on Wednesdays and Thursdays.
It turned out that wpv-conditional shortcodes are not supported inside forms. Also, we cannot use Forms conditional groups on a field(status) that does not exist in the form.
To work around this, we'll use two forms, one for Rejected users and the other for Approved users. I cloned the existing form and wrapped the organization field inside a disabled field set:
<fieldset disabled>
<div class="form-group">
<label>[cred_i18n name='org-label']Organization[/cred_i18n]</label>
[cred_field field='org' force_type='field' class='form-control' output='bootstrap']
</div>
</fieldset>
Then, I used a Fields&Text block to display one of the forms based on the current user status:
[wpv-conditional if="( '[types usermeta='request-status' current_user='true'][/types]' eq 'Rejected' )"]
[cred_user_form form='update-user-form-readonly']
[/wpv-conditional]
[wpv-conditional if="( '[types usermeta='request-status' current_user='true'][/types]' eq 'Approved' )"]
[cred_user_form form='update-user-form']
[/wpv-conditional]
Additionally, I would like to note some "issues" that you may want to address.
- Every user can update his data(status, organization, etc.) on his profile page.
You may want to disable access to it hidden link
Or you may want to make the status field only available for admins using The Toolset Access https://toolset.com/course-lesson/access-control-for-custom-fields/
- For more security, you may want to add custom validation for these forms. And make sure the organization field is only updated when the current user has all the requirements(is not rejected). https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate
Many thanks Jamal for your suggestions. I will work on it and I will come back to you.
Awesome! I am glad I could help.
I'll set this ticket as waiting for your feedback, which will keep it open for 3 weeks until you mark it as resolved or you get back to us for further assistance.
All the best,
Jamal