Home Forums ACF PRO Show/Hide groups based on select value (Javascript)


Show/Hide groups based on select value (Javascript)

  • A long time ago I implemented a project where an ACF block should only be displayed if you have selected a certain value in a select box.

    ACF only offered this option when editing an existing record, not via Javascript when changing the select box.

    But there was the following plugin, which suddenly doesn’t work with the latest versions of WordPress and ACF anymore:

    Has this finally been integrated directly, or is there another solution?

  • No, this has not been implemented and I have not updated the plugin you referenced in a long time. There have been a lot of changes in ACF since I created that and I’m not likely to update it. The main reason being that it is very poor for performance. On top of this, the JS code in ACF has been completely rewritten since then. I don’t know what I’d need to do to make it work or even where to begin at this point and I don’t really have the time to look into it.

    Doing a search I can’t come up with a solution for you.

    I would suggest that you look at the JS file in the plugin
    1) acf.ajax.extend() no longer works
    2) you need to figure out how to add the actions to the fields without using `acf.ajax.exend()
    3) you need to figure out what function in the ACF JS to call to cause it to update the field groups, this used to be .update($field, $value).fetch();

  • Thank you very much for the detailed answer. If the customer doesn’t like the fact that he can see all groups now, we will try to change the plugin accordingly. I hope that ACF will soon implement a solution directly, because this is actually an elementary feature.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.