Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing only last field #1

Closed
garrettboatman opened this issue Nov 6, 2013 · 9 comments
Closed

Importing only last field #1

garrettboatman opened this issue Nov 6, 2013 · 9 comments

Comments

@garrettboatman
Copy link

This doesn't seem to be working with the most current version of ACF. I've tested it with a few WP installs, & it looks to be Recovering the field group correctly, but only the last field in each group. The field group draft (immediately after recovering the group) shows the number of fields that should have been recovered, but if you view the draft, it only displays 1 recovered field. Also, after you publish the group, the recovered field number updates to 1(in the field group list).

@socialblogsite
Copy link

Same here. The only field imported appears as #2 in the sort order, and any new field you create takes the #1, since the javascript in the browser didn't get any field #1.

Trying it on newer versions of ACF don't even import a thing.

What version of ACF was this created for?

@seamusleahy
Copy link
Contributor

This was created for ACF 3. I haven't tested with ACF 4 yet, I'll try to figure it out next week.

@dotKev
Copy link

dotKev commented Dec 3, 2013

This little patch fixes fields import for ACF 4. It still doesn't properly import locations or options, but it's a start.

diff --git wp-content/plugins/ACF-PHP-Recovery-master/acf-php-recovery.php wp-content/plugins/ACF-PHP-Recovery-master/acf-php-recovery.php
index 6a594157d7a761bf9ee2e853050be82411efc6e9..3e80032431e96aed9130798b9c9793e5ac312f97 100644
--- wp-content/plugins/ACF-PHP-Recovery-master/acf-php-recovery.php
+++ wp-content/plugins/ACF-PHP-Recovery-master/acf-php-recovery.php
@@ -43,7 +43,13 @@ function acf_php_recovery_page() {
         }

         // Fields
+        $order_no = 0;
         foreach($fieldset['fields'] as $field) {
+          if(isset($field['order_no'])) :
+            $order_no = max($order_no,$field['order_no']);
+          else:
+            $field['order_no'] = $order_no++;
+          endif;
           add_post_meta( $post_id, $field['key'], $field, true);
         }

@garrettboatman
Copy link
Author

@dmh-kevin, just FYI, I'm not getting any change of behavior with the patch.

@dotKev
Copy link

dotKev commented Dec 4, 2013

Before the patch, I was getting the same issue you described. My php field definitions were old, so perhaps an old ACF export didn't provide all of the fields that newer exports have. I'll test more. I only tested against the content on a project where I really did loose the xml dump and database definitions and was able to retrieve all of my fields.

@alekstrust
Copy link

Please update to work with version 4

@iamntz
Copy link

iamntz commented Dec 26, 2013

@alekstrust for ACF4 you could use my little script: https://github.com/iamntz/acf-recovery

Although it doesn't have any option as ACF Recovery does, it will restore all of your fileds ;)

Enjoy!

@seamusleahy
Copy link
Contributor

Thanks to iamntz and dmh-kevin. It is now updated. There is an issue when attempting to edit a recovered fieldset while the PHP defined version is still active.

@garrettboatman
Copy link
Author

You guys rock.

Greg-Boggs pushed a commit to Greg-Boggs/ACF-PHP-Recovery that referenced this issue Jun 5, 2017
MaximeCulea added a commit that referenced this issue Jun 6, 2017
#1 adjust dashboard link to point to correct settings URL.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants