Update Post Meta From Another Custom Field’s Value on Post Publish/Update when using Meta Box

In the Meta Box Facebook group a user asks:

Hi all, wondering if I can get some help. For custom field 1, I am using file_advanced to upload a PDF file.
I am wondering if I can populate custom field 2 with the URL for the PDF file that was uploaded to custom field 1.

This Pro tutorial shows how we can extract the URL from a (PDF) file, a file_advanced type of custom field after a post has been saved (published or updated) and set it as the value of a field of url type (optional: read-only) for that post when using Meta Box.

Add the following in child theme's functions.php (w/o the opening PHP tag) or a code snippets plugin:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Instant access to 390+ Bricks code tutorials with BricksLabs Pro