Skip Navigation

[Resolved] Disable Custom Field in WordPress Dashboard

This support ticket is created 6 years, 5 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by henryH 6 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#1069989

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
}
?>

#1070056

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/

#1070261

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.

#1070778

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

#1077145

Yes