Support

Account

Home Forums General Issues transfer data with (load_value and update_value) vs (get_field and update_field)

Solved

transfer data with (load_value and update_value) vs (get_field and update_field)

  • Hi

    We are currently syncing data between two different CPTs. We use a loop within the current_screen action with get_field and then update_field and occasionally depending on the circumstance of the transfer we use prepare_field to modify the field data before we update it (e.g. its class).

    The question is what is the difference if one used load_value and update_value to achieve the same thing? We are confused about it and want to know if we are doing it properly or if the filters are more efficient then get_field and update_field.

    Thank you

  • I’m a little confused by some of your question.

    load_value (https://www.advancedcustomfields.com/resources/acf-load_value/) and update_value (https://www.advancedcustomfields.com/resources/acf-update_value/) are hooks that allow filtering, they are not functions to call. You can effect the value of these fields after they are loaded and before they are saved. These are not functions that you can call.

    prepare_field is also a hook, this is only used in the admin just before a field is displayed for editing https://www.advancedcustomfields.com/resources/acf-prepare_field/, again, not a function you should be calling directly. Modifying a field value on this hook will not effect the field.

    get_field() and update_field() are the most efficient, and really the only way to get or change the value of a field using ACF.

  • To add to my previous comment,

    Even if you wanted to use the load_value and update_value hooks to do filtering, you’d still need to use get_field() and update_field() to cause those hooks to be fired in the first place. So you’d essentially be creating a filter where one is not really required.

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

The topic ‘transfer data with (load_value and update_value) vs (get_field and update_field)’ is closed to new replies.