I am trying to wrap my head around how to use save_post and update_field to combine a field from a post, as well as an option field, into a new field within said post. I don’t know if I need to create the new field first and somehow hide it from the options form, or if I can have it display after save but make it non-editable.. or if acf just makes it in the background without the need for me to make it first (sorry if that doesn’t make sense).
Here’s what I’m trying to do:
In an acf options page, a user will enter their affiliate id: affiliate_id
When creating a post, they will enter a product number: product_id
When the post is saved I want a new field named “link”, within that post, to automatically combine those values so that the following is saved for the new “link” field:
however, I would not do this. I would assume that there is something in the post that relates that post to the user. When outputting the post I would look up the get the ID value and append it to the url generated by get_permalink() https://developer.wordpress.org/reference/functions/get_permalink/ rather than create and/or update a field holding a link to the page.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users