Home › Forums › ACF PRO › Auto populate new posts by submitting a different post type › Reply To: Auto populate new posts by submitting a different post type
Create an acf/save_post filter that runs after acf http://www.advancedcustomfields.com/resources/acfsave_post/
Be sure to check the post type of the post just saved to prevent an infinite loop.
add_action('acf/save_post', 'create_payslip');
function create_payslip($post_id) {
if (get_post_type($post_id) != 'timesheet') {
return;
}
// get values from $post_id
// use wp_insert_post() to create new post
// use update_field() to update any acf fields
}
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.