Support

Account

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');