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

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

Get access to all 526 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Post Data for the Current User in Bricks with Meta Box

Post Data for the Current User in Bricks with Meta Box

In the Bricks Facebook group a user asked: I need help with Metabox and Bricks! I have created a CPT "SalesRep" with multiple custom fields…
Categories:
Pro
Meta Box Group Subfield Text’s Slug as Query Loop Item ID in Bricks

Meta Box Group Subfield Text’s Slug as Query Loop Item ID in Bricks

In the BricksLabs Facebook group a user asks: I have a metaBox custom field called 'section_title' inside a clonable metabox group called 'about_section' How can…
Categories:
Tags:
Output HappyFiles Folders in Metabox Select-Field

Output HappyFiles Folders in Metabox Select-Field

This tutorial is part of a series where I'm gonna show you how to output custom HappyFiles Galleries and Sliders. Part one will cover a…
Categories:
Pro
MB Favorite Posts in Bricks

MB Favorite Posts in Bricks

This tutorial explores using MB Favorite Posts in Bricks, including outputting the list of favorites via a query loop.
Categories:
Pro
Meta Box Checkbox List Query Type in Bricks

Meta Box Checkbox List Query Type in Bricks

This Pro tutorial provides the steps to add a new query type in Bricks builder for displaying the values of a Checkbox List type of…
Categories:
Pro
Ordering Meta Box group rows by a sub field in Bricks

Ordering Meta Box group rows by a sub field in Bricks

In the BricksLabs Facebook group a user asks: Any idea how to set the sort order of a cloneable group in the query? In this…
Pro
Dynamic Post-specific Templates in Bricks using Meta Box/ACF Select Field

Dynamic Post-specific Templates in Bricks using Meta Box/ACF Select Field

Update on 23 Aug 2023: Added steps for ACF. Bricks builder v1.8.4 introduced an pretty useful filter called bricks/active_templates that flew under the radar. This…