Hello,
Wordpress revision does not show the correct username on revision. It shows the field changes, but on user it shows, the last user who edited post content or post title, not the user changed the ACF field values.
Have tried this hook, did not worked.
// On ACF update change Author
add_action('acf/save_post', 'trigger_revision_with_author_on_acf_update', 20);
function trigger_revision_with_author_on_acf_update($post_id) {
// Check if this is an autosave or a revision to prevent unnecessary revisions
if (wp_is_post_revision($post_id) || wp_is_post_autosave($post_id)) {
return;
}
// Get the current post object
$post = get_post($post_id);
// Ensure it's a valid post object
if ($post) {
// Create a new revision for the post
$revision_id = wp_save_post_revision($post_id);
// Check if a revision was successfully created
if ($revision_id) {
// Get the current user info
$current_user = wp_get_current_user();
$new_author_id = $current_user->ID;
// Update the revision's author to the current user
wp_update_post([
'ID' => $revision_id,
'post_author' => $new_author_id, // Set the revision author
]);
}
}
}