Support

Account

Home Forums ACF PRO Meta Location Rules for ACF5?

Solving

Meta Location Rules for ACF5?

  • For ACF 4 I was using https://wordpress.org/plugins/advanced-custom-fields-meta-location-rule/ to create meta location rules. However the plugin doesn’t seem to work for ACF 5.

    What I have is 2 field groups with options then another field group with a radio selector. I want the first 2 field groups to show based on the selection in the 3rd field group.

    I could group it all into one field group and use conditional rules but it get’s really messy with that man options.

    Any ideas?

  • Yup i also got the same problem. After checking the code i found out that with the field_group.js

    It was calling an id that does not exist in the new version of acf.

    so i tried removing the id from the jquery selector
    $(‘.location-groups td.value select:visible’)

    Now the input field for the meta key and value is already being shown but the problem now is that when you try to update. It seems that the meta key and value are not being saved. Another problem is that there seems to be a problem with the js file preventing you from adding more rules.

    I hope this gets fixed as well. Need this on one of my project.

  • There are several plugins in the repo that erroneously say they are for ACF4+ and don’t actually work with 5. You’ll need to talk to plugins’ authors.

  • same. has anyone sussed this out?

  • Actually, since posting my last comment here I have created a plugin that does this. However, the plugin can slow down your admin and it’s not really a good idea unless you really need it. You can dig through my code and implement it for your specific fields on the site.

    Like I said, while I build this I would not use it as it will run JS on every choice field in all field groups one the page and it would be better to target only your specific field. For example, targeting a specific select field would look something like

    
    // replace data-key with your field key
    'change [data-key="field_12345678"] select': '_custom_field_location_change_select'
    

    https://github.com/Hube2/acf-custom-field-locations-rule

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

You must be logged in to reply to this topic.