Home › Toolset Professional Support › [Resolved] I want to hide a specific field only in the back-end.
Problem: I would like to hide a specific custom field in wp-admin.
Solution: Use CSS enqueued in your theme:
.wpcf-group-area.wpcf-group-area_userdata > .wpcf-profile-field-line .wpcf-profile-field-line:nth-child(9) { display: none; }
Relevant Documentation:
https://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts
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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
Tagged: Toolset Forms, User-registration forms
Related documentation:
This topic contains 8 replies, has 2 voices.
Last updated by suryaS 6 years, 3 months ago.
Assisted by: Christian Cox.
I am trying to:
Hide a specific field which is added to the user's profile thru the form I have created. I only want to hide it in the back-end from admin. I tried using this code
.wpcf-group-area.wpcf-group-area_userdata {
display: none !important;
}
But it hides the whole form in the back-end. I don't want to hide the whole form only one field in the form.
I can't get around this because the class name for all the fields are the same "wpcf-profile-field-line".
In CSS, you could use the nth-child selector to target one field in the group like this:
.wpcf-group-area.wpcf-group-area_user-details > .wpcf-profile-field-line .wpcf-profile-field-line:nth-child(1) { display: none; }
The number is a one-based index of sibling elements.
A JavaScript solution would be to look for the field then find the closest ancestor .wpcf-profile-field-line and hide it.
Hi Christian,
Thanks for your quick reply. Regarding "In CSS, you could use the nth-child selector to target one field in the group like this:" So if I use the nth-child, do I count which field line its on? Sorry I just did get how to locate the field number since there are not being displayed.
Sorry but I just don't get how to use the nth-child.
You can manually count the number of sibling rows above the row you wish to hide. If you add or remove custom fields to this field group above this custom field, you must change the nth child number to match the new position of the field. I just realized I made a mistake earlier - it's a 1-based index, not a 0-based index. So the first child is nth-child(1), the second child is nth-child(2), and so on. I'll update my earlier comment to fix that.
I tried this but it didn't work. I counted the number of rows like you said.
.wpcf-group-area.wpcf-group-area_user-details > .wpcf-profile-field-line .wpcf-profile-field-line:nth-child(9) {
display: none;
}
May I log in to your wp-admin area to see what's going on here? Private reply fields are enabled.
Let me know which field you are trying to hide.
Looks like I made a typo copying the class name. Try this instead:
.wpcf-group-area.wpcf-group-area_userdata > .wpcf-profile-field-line .wpcf-profile-field-line:nth-child(9) { display: none; }
Thanks!! That worked perfectly..