Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require('wp-blog-header.php');
- define('ANSPRESS_VOTE_META', '_ap_vote');
- define('ANSPRESS_FAV_META', '_ap_favorite');
- define('ANSPRESS_CLOSE_META', '_ap_close');
- define('ANSPRESS_FLAG_META', '_ap_flag');
- define('ANSPRESS_VIEW_META', '_views');
- define('ANSPRESS_UPDATED_META', '_ap_updated');
- define('ANSPRESS_ANS_META', '_ap_answers');
- define('ANSPRESS_SELECTED_META', '_ap_selected');
- define('ANSPRESS_BEST_META', '_ap_best_answer');
- define('ANSPRESS_PARTI_META', '_ap_participants');
- define('AP_FOLLOWERS_META', '_ap_followers');
- define('AP_FOLLOWING_META', '_ap_following');
- $question_title = "This space is for Question Title...";
- $user_id = 1;
- $question_description = "This space is for actual/detailed question post";
- $category = array(12, 13, 15);
- $tags = array(21, 22, 23);
- $status = 'publish';
- $question_array = array(
- 'post_title' => $question_title,
- 'post_author' => $user_id,
- 'post_content' => wp_kses($question_description, ap_form_allowed_tags()),
- 'post_type' => 'question',
- 'post_status' => $status
- );
- $post_id = wp_insert_post($question_array);
- if ($post_id) {
- wp_set_post_terms($post_id, $category, 'question_category');
- wp_set_post_terms($post_id, $tags, 'question_tags');
- update_post_meta($post_id, ANSPRESS_VOTE_META, '0');
- update_post_meta($post_id, ANSPRESS_FAV_META, '0');
- update_post_meta($post_id, ANSPRESS_CLOSE_META, '0');
- update_post_meta($post_id, ANSPRESS_FLAG_META, '0');
- update_post_meta($post_id, ANSPRESS_VIEW_META, '0');
- update_post_meta($post_id, ANSPRESS_UPDATED_META, current_time('mysql'));
- update_post_meta($post_id, ANSPRESS_SELECTED_META, false);
- ap_add_parti($post_id, $user_id, 'question');
- update_post_meta($post_id, ANSPRESS_ANS_META, '0');
- do_action('ap_after_inserting_question', $post_id);
- ap_do_event('new_question', $post_id, $user_id);
- $question_permalink = get_permalink($post_id);
- }
- echo "<a href='$question_permalink'>link</a>";
Advertisement
Add Comment
Please, Sign In to add comment