ACF_Form_Post::save_post
save_post
Triggers during the save_post to save the $_POST data.
Method of the class: ACF_Form_Post{}
No Hooks.
Returns
Int.
Usage
$ACF_Form_Post = new ACF_Form_Post(); $ACF_Form_Post->save_post( $post_id, $post );
- $post_id(int) (required)
- The post ID.
- $post(WP_POST) (required)
- the post object.
Changelog
| Since 1.0.0 | Introduced. |
ACF_Form_Post::save_post() ACF Form Post::save post code ACF 6.0.4
function save_post( $post_id, $post ) {
// bail early if no allowed to save this post type
if ( ! $this->allow_save_post( $post ) ) {
return $post_id;
}
// verify nonce
if ( ! acf_verify_nonce( 'post' ) ) {
return $post_id;
}
// validate for published post (allow draft to save without validation)
if ( $post->post_status == 'publish' ) {
// bail early if validation fails
if ( ! acf_validate_save_post() ) {
return;
}
}
// save
acf_save_post( $post_id );
// save revision
if ( post_type_supports( $post->post_type, 'revisions' ) ) {
acf_save_post_revision( $post_id );
}
// return
return $post_id;
}