Home › Forums › General Issues › Prepopulate Fields from Other CPT › Reply To: Prepopulate Fields from Other CPT
I decided to pull the data from wp_option table instead so that the client will have an easy to find place to update contact information.
Now, I have tried many variations on this. The variable is getting the data from option but the field is not updating. As you can see I wan this to work with several fields but I’m starting with just the name because I cannot even get that to work. Any idea what I’m doing wrong here?
function add_contact_info_to_post( $post_id ) {
$mm_restaurant_name = the_field('mm_restaurant_name', 'option');
$mm_phone = the_field('mm_phone', 'option');
$mm_email = the_field('mm_email', 'option');
$mm_location = the_field('mm_location', 'option');
$field_key = 'field_56e5f9f891134';
update_field($field_key, $mm_restaurant_name);
}
add_filter( 'acf/save_post', 'add_contact_info_to_post' );
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.