OK I figured it out. My fault! Sorry.
I had an extra line calling the acf/update_value filter in the page template hooked to the wrong function.
Just an update to confirm that it still doesn’t work in ACF 5.5.3.
Hi James!
Thank you so much for your help!!!
https://gist.github.com/ty2u/b4ce1e251a0ead2ebb2c6ae69c407774
Hopefully it makes sense to you.
#1 still seems to have issues but I’m thinking #2 is a browser feature/bug because I can now only reproduce it sometimes and it goes away after I close the browser and open it again, which incidentally required me to retype this whole post haha.
Further inspection has proved #2 to be caused by the Inspector. Only when I open the Developer Tools/Inspector in Google Chrome it doesn’t ask to resubmit the form once it’s submitted the first time and then I try refreshing the page while the Inspector is open. The page just refreshes without the alert to ask if you want to resubmit it. If I close the Inspector and try to submit it then prompts me to continue or not again. I never noticed this feature before.
I also tried some javascript mentioned on here https://www.advancedcustomfields.com/resources/acf_form/ that didn’t seem to do anything but I probably didn’t do it right:
jQuery(document).ready(function () {
"use strict";
// frontend feedback acf form
if(jQuery("div[id^='feedback-entry-']").length > 0) {
acf.do_action('append', jQuery('#acf-form'));
}
});
I also tried this in functions.php instead of the above js to no avail:
add_action( 'wp_head', 'add_acf_js' );
function add_acf_js() {
echo '<script>(function($) {
// setup fields
acf.do_action("append", $("#acf-form"));
})(jQuery);
</script>';
}
Thanks again!
Well I think upgrading the server just to upgrade this plugin would be pretty silly. I was thinking maybe there was some other manual way to upgrade and for some reason didn’t think raising the memory limit would actually do anything but it did! After setting it to 2 gigs it went through and completed the upgrade. Thank you!
Another bit of code to go with the previous one that updates all previously created posts of type my_custom_post_type with the extra meta data instead of having to manually do it.
/**
* Update post meta for sortable column
*/
if (is_admin() && isset($_GET['addsortablemeta']) && $_GET['addsortablemeta'] == 1) {
$args = array(
'post_type' => 'my_custom_post_type',
'nopaging' => true,
);
$my_query = null;
$my_query = new WP_Query($args);
if ($my_query->have_posts()) {
while ($my_query->have_posts()) : $my_query->the_post();
my_acf_save_post($post->ID);
endwhile;
}
wp_reset_query();
}
/**
* acf/save_post filter to create custom sortable usernames field
*
* @param array $post_id
*/
function my_acf_save_post( $post_id ) {
// get users from ACF field
$my_users = get_field('my_users');
// get usernames
$usernames = array();
foreach($my_users as $my_user) {
$usernames[] = $my_user['nickname'];
}
$value = implode(", ", $usernames);
// add usernames to sortable field
update_post_meta($post_id, 'my_users_sortable', $value);
}
add_action('acf/save_post', 'my_acf_save_post', 20);
You are a genius! That sounds like it’ll do the trick nicely. Thank you for taking the time to share your knowledge!
I figured maybe the old single valued fields with “required” in them were probably just messed up so I converted them all to the same format and they seem to work correctly. But now I’m still not 100% sure how to go about sorting them properly. I suppose maybe I just have to get their username associated with the query somehow and sort by that.
Thanks for your help =)
Hi there,
Sorry it took so long to get back to this! Have been awaiting approval to move ahead but now have it.
At present the site has ACF Pro Version 5.3.7. This site is usually keeping up with the latest ACF Pro version fairly closely, though lags behind sometimes for a number of weeks until we get time to update and test everything. It’s been using it for a fair amount of time so it could have been caused by an older version. I probably could get approval to update it to the latest version which at this time appears to be 5.3.9.2.
By the sounds of it maybe there was a bug at one point somewhere or another which affected the fields in the db. I’m not sure if in the code on the site or ACF or what but if the word “required” is showing up in that field in the db something definitely seems wrong somewhere if it shouldn’t be there. So if I remove the word required and take the single and multi-selection values into consideration then maybe it will sort properly. I will test that out. Thanks!
It does allow selecting multiple values in the field settings.
The field is a User field type.
Thank you for your great answers! They helped me a lot!
Thank you for your response!
So what if a post or term that uses them was added and then the menu was removed?
It was an ACF option page, which basically seemed like a post to me which I could assign custom fields to so if custom fields were added to it and then removed and then the menu was removed in the code would the menu item then stay?
I will also check to see about a cache or some rogue file on the server or something.
Yes but it seems that WP has it hardcoded in to set it to 256MB for admin screens for some reason and that wasn’t enough for this many posts.
Maybe this is helpful to someone. In order to increase memory on the admin screens I put this in my themes functions.php file.
function theme_increase_mem_limit($wp_max_mem_limit) {
return "512M";
}
add_filter('admin_memory_limit', 'theme_increase_mem_limit',10,3);
Actually now that you mention it I think maybe the memory limit could have been hit before but I have it set to 512M now and that seemed to work before upgrading and didn’t crash that Android Internet browser. Only after implementing AJAX/upgrading to ACF 5.0 Pro were these more noticeable delays when hovering or clicking the field and crashing that app present.
Yep, it filters by a post type which contains from 35-40k posts. The “Filter by Post Type” field has a single entry. The Filters field has Search checked. Return Format is Post ID. The rest should be defaults.
I know the number of posts is the reason as I’ve run into countless other performance issues I’ve managed to work around or resolve. It didn’t have this issue before the AJAX was implemented therefore maybe an option to not use the AJAX or somehow automatically disabling AJAX if there are more than a certain number of posts for that particular post type could prevent the slowness and crashing.
I’m personally fine with it the way it is now that I’m home and can work from my desktop but I imagine people with less powerful servers and clients would have much more of an issue with even many less posts than I have.
Extra testing results: On my desktop in Opera the page takes about 8-10 seconds to load. On a Galaxy Note 4 in the Android Internet app it crashed. In Android Chrome it loaded eventually but very slowly. Additionally, hovering over the field when editing the field group is a bit slow as well as opening the field to edit it.
Indeed. Well like I said, it seems to be caused by the relationship fields. But oh well. Back home now and works fine in my desktop browser, even if it is a little slow. Thanks.
Hi there,
I am having a very similar issue. But mine happens on relationship fields. I never had any issues until we upgraded to 5.0 pro.
We have a very powerful dedicated server. I think it’s something to do with the Javascript or AJAX. It’s unusable for me now and I can’t even work on it from my phone because it crashes the browser tab.
I do also have a couple repeater fields.
Finally, and likely part of the issue is that we have about 38k posts in the database and about 10 million entries in the post meta table.
Maybe an option to disable the AJAX would fix it. Not sure.
Not sure what to do but it’s somewhat urgent so if you’re able to do anything to help that would be amazing!
Thank you for the exellent software!
Ryan
Yep, that did the trick. Thanks!
Just had to switch update_field to update_post_meta and move the postid to the start and add serialize to the array.
serialize
http://php.net/manual/en/function.serialize.php
update_post_meta
http://codex.wordpress.org/Function_Reference/update_post_meta
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.