Redirect to File attached to a Post using ACF

The action redirect_to_acf_file_url doesn’t exist, at least not in stock WordPress. You’ll need to supply a proper action hook, and it’ll need to be one that happens before any output is sent to the browser. I’d recommend something like init or wp.

add_action() takes a hook name and a function name.

<?php
function redirect_to_acf_file_url() {
  $file_url = get_field('file_url');

  if (!empty($file_url) && is_string( $file_url ) ) {
    wp_redirect( esc_url( $file_url ), 301);
    exit;
  }
}
do_action ( 'wp', 'redirect_to_acf_file_url' );
?>

References

tech