Home › Forums › Backend Issues (wp-admin) › Change fields in WordPress profile page when selecting option › Reply To: Change fields in WordPress profile page when selecting option
The problem is that you’re targeting the id using the field name. ACF does not actually use the field name when displaying fields. Take a look at the source of the wp admin form. Instead is uses the field keys. You’re code should look something like:
unction my_acf_admin_footer() {
?>
<script type="text/javascript">
jQuery(document).ready(function($){
// use field key here
$("#acf-field_566afb46d86cf").change(function () {
var val = $(this).val();
if (val === "pj") {
$("#acf-razao_social").closest("tr").hide();
}
if (val === "pf") {
$("#acf-razao_social").closest("tr").hide();
}
if (val === "mei") {
jQuery("h3:contains('PJ - Transportadora')").next(".form-table").hide();
}
});
});
</script>
<?php
}
add_action('acf/input/admin_head', 'my_acf_admin_footer');
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.