Skip to content

Instantly share code, notes, and snippets.

@atultiwari
Created November 28, 2017 07:05
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 atultiwari/a7c5cfb43324b08125a2cbec6bd15a02 to your computer and use it in GitHub Desktop.
Save atultiwari/a7c5cfb43324b08125a2cbec6bd15a02 to your computer and use it in GitHub Desktop.
<?php
$form = anspress()->get_form( 'answer' );
$values = array(
'post_content' => $mcq_answer,
'post_type' => 'answer',
'post_status' => 'publish',
'post_parent' => $anspress_question_id,
'comment_status' => 'open',
);
$form->set_values( $values );
$post_id = AP_Form_Hooks::submit_answer_form( true );
//$post_id = wp_insert_post($values);
$answer_permalink = get_permalink($post_id);
echo "Post ID : " . $post_id . "<br>";
// Make sure post is inserted.
if ( ! is_wp_error( $post_id ) ) {
$anspress_answer_posted = true;
} else {
$anspress_answer_posted = false;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment