It would be helpful for me if you can give the solution.
There is one custom field called "Status" in Registration form(Created using User form) By default I am storing "New" in Status field. Admin can Change the status of the user(this functionality is completed). But User can't change his own status.(This functionality is left)
I tried using Jquery but it is not working.
Below is the code which I have used.
add_action('admin_head','hide_personal_options');
function hide_personal_options() {
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#wpcf[selstatus]').attr('disabled', 'disabled');
});
</script>
<?php
}
?>
Hello,
You don't need to setup custom codes, there is a built-in feature within Toolset Access plugin, you can setup access to the custom fields for different user roles.
See our document:
Access Control for Fields
https://toolset.com/documentation/user-guides/access-control-for-user-fields/
I don't want to restrict all the fields. I just want to set readonly to "Status" field. Because user can update his basic detail but he can't update "Status". And "Status" is the custom field.
Then the custom codes is required, I assume we are talking about a custom select field, the field slug is "selstatus", you can modify your PHP codes as below, and test again:
add_action('admin_head','hide_personal_options');
function hide_personal_options() {
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('select[name="wpcf[selstatus]"]').attr('disabled', 'disabled');
});
</script>
<?php
}
?>
More help:
hidden link