Hi Rahul,
As you know, sometimes to post new questions on my site, I use customized function, which creates CPT – Questions and Answers (code snippet posted below). They both are created and posted fine with my function. But they are missing the relevant meta activities. So my questions are –
- What are different meta activities used by AnsPress while creating/updating a question/answer, specially how to use “__ap_activity” with my function?
- How to find all the functions/meta activities (by different plugins) in general (not localized to anspress only), which are triggered on creating a new question/answer? [I am particularly interested in finding what is triggered in “Next Scripts: Social Networks Auto Poster”, because, I found that this plugin does work with AnsPress, but only when I create the new question from AnsPress itself, it does NOT trigger when I create the new question from my customized function. I want it to trigger from my function, but I couldn’t figure out how to do that?]
- OR, is there any way, by which wordpress can automatically process, all the functions etc. after creating the new post with `
wp_insert_post
` just like it does automatically when new post is created from admin section?
Relevant part of my function –
https://gist.github.com/atultiwari/01c130e0da0cb58d51b3a990d031e404
<?php function AddQuestionToAnsPress($question_title, $question_content, $answer_content, $subject_id, $exam_id) { $path = $_SERVER['DOCUMENT_ROOT']; $path .= "/wp-blog-header.php"; require($path); $question_title = strip_tags($question_title); $category_id = $subject_id; $category = array($category_id); $tag_subject_id = $subject_id; $tags = array(25, $tag_subject_id); wp_set_current_user(26); $user_id_for_question = 26; $question_array = array( 'post_title' => $question_title, 'post_author' => $user_id_for_question, 'post_content' => $question_content, 'post_type' => 'question', 'post_status' => 'publish', 'comment_status' => 'open' ); $question_post_id = wp_insert_post($question_array); $question_permalink = get_permalink($question_post_id); wp_set_post_terms($question_post_id, $category, 'question_category'); wp_set_post_terms($question_post_id, $tags, 'question_tag'); update_post_meta($question_post_id, '_at_exam_id', $exam_id); if ($question_post_id && $answer_content != "") { wp_set_current_user(26); $user_id_for_answer = 26; $ans_array = array( 'post_author' => $user_id_for_answer, 'post_content' => $answer_content, 'post_type' => 'answer', 'post_status' => 'publish', 'post_parent' => $question_post_id, 'comment_status' => 'open', ); $answer_post_id = wp_insert_post($ans_array); } if ($answer_post_id) { update_post_meta($question_post_id, '_ap_selected', $answer_post_id); update_post_meta($answer_post_id, '_ap_best_answer', 1); } $anspress_link = $question_permalink; return array('anspress_link' => $anspress_link, 'question_post_id' => $question_post_id, 'answer_post_id' => $answer_post_id); } ?>
Thanks.
thanks for this wonderful plugin. works great with buddypress profiles and good integration with bp activity stream
this has been asked before also
https://wordpress.org/support/topic/buddypress-groups?replies=6
https://wordpress.org/support/topic/buddypress-groups-integration?replies=2
this is badly needed. i want to do away with bbpress forums for groups and use your plugin for groups.
My client needs to alert all users (several hundred) on their WordPress site every time a new question is posted. I see with the Email add-on that it’s possible to configure this for administrators, but it seems that the required functionality doesn’t exist for users.
This plugin looks very promising for the needs of my client, but they need functionality to upload PDF, DOC, XLS, DOCX, and XLSX files at very least, if not others. Is there any way to enable this?
In my question page I don’t see the “Question Title”.
How is it possible to add this tag bar with stats under the title of the question like you have in this page?
I wish some features below can available:
- When user’s being at a category page and do “Ask question”, then this category will be selected automatically (at dropdown list).
- In category dropdown list (of ask form), insert a empty row as default, when user post question without select a category, the notice will appear “Please choose a category…”. It help user can post right category.
- Customize category more than (background, icon, text color,…).
Please think about this.