I have a function that I use that ties into the publish_page action that I use to create multiple pages on my site. This function worked perfectly for a while, but ceased to function correctly after a recent update. Unfortunately I didn't notice it at the time, nor did the client, so I'm not sure exactly which update killed it.
The issue is that if I try and get the pages custom fields using the post id that is passed into the function, they are not saved to the database yet.
For instance:
function tk_publish_pub($post_id) {
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
$slug = 'pubs';
//get all the pages to copy
while(the_repeater_field('default_pub_pages','options')):
$post_object = get_sub_field('page_template');
$pages_to_copy[] = $post_object->ID;
endwhile;
$admin_user = get_field("admin_user", $post_id);
$allpages = implode(", ", $pages_to_copy);
mail("[email protected]", "test data", "Post ID: $post_id \n Admin user for post: $admin_user \n Pages to copy: $allpages \n Post_name: " . get_field('subdomain_id', $post_id));
return;
}
ACF works correctly at this stage (I get my list of 'pages to copy') so I know its not that. However, where I try and get the admin user, it and any other ACF field from the published page are not saved to the database yet.
Anyone ran into this before?