Home › Forums › ACF PRO › acf_form in wp-admin › Reply To: acf_form in wp-admin
Hi @ryandorn
You need to get the posted data by using the $_POST
global variable because ACF won’t be able to save it correctly. Maybe something like this:
// Action Hook
function my_save_form($cpt_id) {
if(is_admin()){
// Check the posted data
if( isset($_POST['acf']['field_012345678901a']) ){
// Set it to a variable
$posted_data = $_POST['acf']['field_012345678901a'];
// Update the custom field
update_field('field_name', $posted_data, $cpt_id);
// or use update_post_meta
//update_post_meta($cpt_id, 'test', $posted_data);
}
}
};
add_action('acf/save_post', 'my_save_form', 20);
Hope this helps 🙂
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.