Support

Account

Home Forums General Issues Populate text field dynamically with another field

Solved

Populate text field dynamically with another field

  • Hi.

    On post save, I want to dynamically populate a text field using an image field.

    So after I add an image to the image field [logo] and hit save/publish, I would like the image url to populate a text field [logo_url].

    This is due to a client using a plugin that only works with meta keys and the meta key for the image is the ID, so I need to auto-populate a text field with the url.

  • Got it!

    function my_acf_save_post( $post_id ) {
        
        // get new value
        $value = get_field('logo');
        
        // do something
        update_field('logo_url', $value);
    }
    
    add_action('acf/save_post', 'my_acf_save_post', 20);
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Populate text field dynamically with another field’ is closed to new replies.