Created
November 27, 2017 09:06
-
-
Save rahularyan/4f9d0b0d3058be1bea5f63f6720750ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$form = anspress()->get_form( 'question' ); | |
$values = array( | |
'post_title' => 'Question title goes here', | |
'post_content' => 'Question description goes here', | |
'is_private' => false, // True if not private. | |
'category' => 5, // Id of taxonomy term. | |
'tags' => array( | |
23 => 'WordPress', | |
25 => 'Joomla', | |
27 => 'Website', | |
), // question_tag taxonomy term in id=>name format. | |
) | |
$form->set_values( $values ); | |
$post_id = AP_Form_Hooks::submit_question_form( true ); | |
// Make sure post is inserted. | |
if ( ! is_wp_error( $post_id ) ) { | |
$form = anspress()->get_form( 'question' ); | |
$values = $form->get_values(); | |
$qameta = array( | |
'last_updated' => current_time( 'mysql' ), // When last question was active. | |
'answers' => ap_count_published_answers( $post_id ), // numbers of answers. | |
'anonymous_name' => sanitize_text_field( $values['anonymous_name']['value'] ), // Anonymous user name. | |
'selected' => false, // Answer id if have a selected answer. | |
'views' => 10000, // Numbers of views. | |
'closed' => false, // Is question closed? | |
'comments' => 10, // Numbers of comments. | |
'featured' => false, // is featured? | |
'votes_up' => 5, // Numbers of vote up. | |
'votes_down' => 0, // Numbers of vote down. | |
'subscribers' => 10, // Numbers of subscribers. | |
'flags' => 0, // Numbers of flags. | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment