Home Forums General Issues Prepopulate Fields from Other CPT Reply To: Prepopulate Fields from Other CPT

  • I decided to pull the data from wp_option table instead so that the client will have an easy to find place to update contact information.

    Now, I have tried many variations on this. The variable is getting the data from option but the field is not updating. As you can see I wan this to work with several fields but I’m starting with just the name because I cannot even get that to work. Any idea what I’m doing wrong here?

    function add_contact_info_to_post( $post_id ) {
      $mm_restaurant_name = the_field('mm_restaurant_name', 'option');
      $mm_phone = the_field('mm_phone', 'option');
      $mm_email = the_field('mm_email', 'option');
      $mm_location = the_field('mm_location', 'option');
      $field_key = 'field_56e5f9f891134';
      update_field($field_key, $mm_restaurant_name);
    add_filter( 'acf/save_post', 'add_contact_info_to_post' );