Home › Forums › Backend Issues (wp-admin) › Read content of uploaded PDF file and save it ACF field › Reply To: Read content of uploaded PDF file and save it ACF field
change
$document_file = get_field('document_file', $post_id);
to
$document_file = get_attachment_file(get_field('document_file', $post_id, false));
setting the last parameter false
for ACF gets the unformatted value, in this case the attachment ID. The WP function get_attachment_file() loads that file into the variable. Then you can pass this to convert it to text.
Then you call update_field() to update the text field with what is returned.
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.