Support

Account

Home Forums Backend Issues (wp-admin) Functions not reached in acf plugin

Solved

Functions not reached in acf plugin

  • I recently created an extension for ACF, namely a City Selector. It creates a field where you can select a country, then a state/province and then a city in the selected state. I built it with the help of Eliot’s template.

    With the Pro version, everything works as expected, but I’m having some issues with the Free version. I can’t seem to get a few functions to load/hook (or they load in a different place than expected).

    These are functions are:
    – update_value : I wanted to use this to validate the value but placing a die() in there doesn’t get reached.

    – load_value : I wanted to use this to add more values to the outputted value (like the_field/get_field). Also here a die() doesn’t get reached (only when in the admin).

    – format_value : After load_value didn’t seem to work I tried this one. Also nu luck in reaching this function.

    I then tried to get the value by using acf/format_value/type-acf_city_selector (in the main plugin file) but this function was not reached. I used priorities 1, 5, 10 and 20.

    You can see the entire plugin here on Github. The file in question which contains these 3 functions is the v4 version.

    I already addressed the issue partially in someone else’s ticket, but that topic is now resolved, so I’m continuing it here.

    PS everything tested on a vanilla WP with twentyseventeen.

  • Solved.

    Problem due to incorrect ‘name’ attributes used in the field HTML:
    https://github.com/elliotcondon/acf-field-type-template/issues/36

    Thanks
    Elliot

  • Thanks for the quick reply @elliot
    I hope this will fix the issue.
    Will start testing this in a bit….

    I wanna fix this asap because I think it’s a great addition to ACF.

  • I am sorry to say this did not fix the issue.

    TBH I was already wondering why this would work because I have no issues with the selects. They are generating/showing/saving as expected.

    I would like to override the value for get_field, as I did here.

    I thought I could do this with load_value but placing an exit; in there doesn’t exit the function while it runs, so I therefor conclude it’s not reached.

    The same happens for update_value, where I would like to add verification, like I did here.

    Hoping you can help me further.

  • I can’t seem to re-open the topic so I hope you’ll see this.

    I noticed that if I dump get_field in create_field 5 values are returned (as expected).

    If I dump $field in load_value (just before the return) 5 values are returned (in the admin).

    Can it be this function doesn’t work on the front-end ? If so how do I override the value ? I tried using acf/load_value but this didn’t work.

    Can this be because my plugin loads before ACF (mine is called acf-city-selector, which loads before advanced-custom-fields) ?

    If I dump get_field in header.php of a template only 3 values are returned.

    Update_value I can’t seem to reach in any way.

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

The topic ‘Functions not reached in acf plugin’ is closed to new replies.