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
    $post_object = get_sub_field('page_template'); 
    $pages_to_copy[] = $post_object->ID;

$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));

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?

1 Answer 1


ACF saves its data on the save_post action, which runs after a post or page status is transitioned to publish. If you want to access field data hook it to the save_post action instead.

  • I'll have to double check this in a little bit... but if that is correct, when was this changed? As I mentioned in the post, the publish_page hook worked fine for many months. Commented Dec 4, 2013 at 1:29
  • I'm not sure, it's been that way as long as I can remember. Also see this post on the ACF help forum.
    – Milo
    Commented Dec 4, 2013 at 1:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.