Home › Forums › General Issues › acf/save_post on specific form › Reply To: acf/save_post on specific form
Perfect, thank you for that.
Would this also be suitable to do if I want to differ from posts that are new or updated?
Or is there a better solution for identifying if the post already exists or if it is new with acf/save_post? Because I want to send an email to the author when they create the post but not when they update it.
I send an url query that identifies if the form should update an existing post or create a new one (by sending post=79 for example). I also use some checks to identify if it is the correct author.
if(isset($_GET['post'])) {
$post_id = $_GET['post'];
}
$correct_author = true;
if(empty($post_id)) {
$post_id = 'new_post';
$submit_value = 'create';
} else {
$submit_value = 'update';
$post_author = get_post_field('post_author', $post_id);
$current_user = get_current_user_id();
if( $post_author == $current_user ) {
$correct_author = true;
} else {
$correct_author = false;
}
}
acf_form(array(
'html_after_fields' => '<input type="hidden" name="acf[' . $submit_value .']" value="true"/>',
));
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.