Skip to content

Instantly share code, notes, and snippets.

@mattkeys
Last active September 7, 2016 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattkeys/ad9c068fd8176d3dd7b78808828911a1 to your computer and use it in GitHub Desktop.
Save mattkeys/ad9c068fd8176d3dd7b78808828911a1 to your computer and use it in GitHub Desktop.
acf_form_head variant
public function new_submission()
{
acf_enqueue_scripts();
if ( ! acf_verify_nonce( 'acf_form' ) || ! acf_validate_save_post( true ) ) {
return;
}
add_filter('acf/pre_save_post', '_acf_pre_save_post', 5, 2);
global $current_user;
$form = array(
'post_id' => 'new_post',
'new_post' => array(
'post_title' => $name,
'post_type' => 'movies',
'post_status' => 'draft',
'post_author' => $current_user->ID
),
'return' => '/manage-movies/files/%post_id%/'
);
$form['post_id'] = apply_filters('acf/pre_save_post', $form['post_id'], $form);
acf_save_post( $form['post_id'] );
$form['return'] = str_replace('%post_id%', $form['post_id'], $form['return']);
wp_redirect( home_url( $form['return'] ) );
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment