Skip to content

Instantly share code, notes, and snippets.

@WadeTheFade
Created October 4, 2018 01:04
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 WadeTheFade/5545dacb9c0843f9d2eca606dc1cc43b to your computer and use it in GitHub Desktop.
Save WadeTheFade/5545dacb9c0843f9d2eca606dc1cc43b to your computer and use it in GitHub Desktop.
class-form-hooks.php
if ( ! $editing ) {
$question_args['post_type'] = 'question';
//$question_args["post_status"] = "draft";
$post_id = wp_insert_post( $question_args, true );
$postToTransition = get_post( $post_id );
clean_post_cache($postToTransition->ID);
//Need to update post via $WPDB or a method here
//anspress()->query->updatePost("publish", $postToTransition);
wp_transition_post_status( "publish", "draft", $postToTransition);
} else {
$post_id = wp_update_post( $question_args, true );
}
if ( ! $editing ) {
$question_args['post_type'] = 'question';
$post_id = wp_insert_post( $question_args, true );
} else {
$post_id = wp_update_post( $question_args, true );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment