Home Forums Backend Issues (wp-admin) Support for "Legacy" Fields Reply To: Support for "Legacy" Fields

  • Unfortunately, this seems to do nothing. I’ve tried several fields, individual values, duplicate values, old_names and new_names, but nothing changes.

    Hm. I hope I’m not stuck with Magic Fields.

    I’ve got an old field, “basic_info_date”, which I’ll try to convert to a new field, “date”.

    add_filter('acf/load_value/name=basic_info_date', 'convert_old_field_to_acf', 10, 3);
    function convert_old_field_to_acf($value, $post_id, $field) {
      if ($value !== NULL) {
        // if the value is not set for ACF yet
        // then the value will be NULL
        // if the current value is not NULL
        // then return because the field already
        // had been set
      // get value from old field
      $old_value = get_post_meta($post_id, 'date', false);
      if (!empty($old_value)) {
        $value = $old_value;
      return $value;

    This displays the Unix base time in 1970 as the date, because the value is null:

    echo '<p>';	
    			echo date('l, F j, Y', strtotime(get_field('date')));
    			echo ' at ';
    			echo get_field('time');
    			echo "<br />\n";

    The time shows up OK because I have a default value set.

    When I modify the field names, am I breaking something? Do I need to erase the group and start over?

    I’m really baffled.